我一直在寻找一段时间,并从SO社区获得了很多帮助。但是,似乎我的项目设置不允许正常查询,如排序,限制,过滤或其他。
我正在查询自定义中间件/ drupal站点。
抛出错误的示例:
{
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
}
]
}
]
}
我该如何解决这些问题?
这是因为你没有在字段limit
上的umdHub
参数。要解决这个问题,让我们在umdHub
类型的Query
字段上检查您的架构,并添加limit
参数,然后重新启动服务器。
例如:
type Query {
umdHub(limit: Int, sort: SortInput) { // <-- Add this
articles
}
}
原来这是做到这一点的方法:
{
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
}
}
}
}