我已经搜索了一段时间,并从SO社区获得了很多帮助。但是,看来我项目的设置不允许诸如排序,限制,过滤器之类的常规查询。
我正在查询自定义的中间件/双站点。
引发错误的示例:
{
umdHub(limit: 5) {
articles {
data {
id
title
subtitle
body
summary
}
}
}
}
或
{
umdHub(
sort: {
fields: [authorship_date___time]
order: ASC
}
) {
articles {
data {
id
title
subtitle
body
summary
authorship_date {
formatted_short
unix
unix_int
formatted_long
formatted_short
time
}
}
}
}
}
http://localhost:8000/___graphql中的所有返回错误,例如:
{
"errors": [
{
"message": "Unknown argument \"limit\" on field \"umdHub\" of type \"Query\".",
"locations": [
{
"line": 2,
"column": 10
}
]
}
]
}
我该如何解决这些问题?
答案 0 :(得分:2)
那是因为在字段umdHub
中没有参数umdHub
。
要解决此问题,让我们在Query
类型的limit
字段上检查您的架构,并添加type Query {
umdHub(limit: Int, sort: SortInput) { // <-- Add this
articles
}
}
自变量,然后重新启动服务器。
示例:
var fileUrls = new[]
{
new Uri("https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/media/image3.5.png"),
new Uri("https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/media/image4.png"),
new Uri("https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/media/image6.png")
};
var downloadResults = fileUrls
.Select(uri => (uri: uri, response: HttpClientFactory.Create().SendAsync(new HttpRequestMessage(HttpMethod.Get, uri))))
.ToArray();
await Task.WhenAll(downloadResults.Select(v => v.response));
using (var ms = new MemoryStream())
{
using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true))
{
foreach (var download in downloadResults)
{
var entry = archive.CreateEntry(download.uri.Segments.Last(), CompressionLevel.Fastest);
using (var zipStream = entry.Open())
{
var data = await download.response.Result.Content.ReadAsByteArrayAsync();
zipStream.Write(data, 0, data.Length);
}
}
}
return File(ms.ToArray(), contentType, $"{zippedFolderName}");
}
答案 1 :(得分:0)
结果证明这是做到这一点的方法:
{
umdHub {
articles (page: { limit: 5 }) {
data {
id
title
subtitle
body
summary
hero_image {
url_1200_630
}
authorship_date {
formatted_short
unix
unix_int
formatted_long
formatted_short
time
}
slug
}
}
}
}