问题
I have been searching around for a while and been getting a lot of help from the SO community. But, it seems that the setup of my project isn't allowing normal queries such as sort, limit, filter, or others.
I am querying a custom middleware/drupal site.
Examples that throw errors:
{
umdHub(limit: 5) {
articles {
data {
id
title
subtitle
body
summary
}
}
}
}
or
{
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
}
}
}
}
}
All return errors in http://localhost:8000/___graphql like:
{
"errors": [
{
"message": "Unknown argument \"limit\" on field \"umdHub\" of type \"Query\".",
"locations": [
{
"line": 2,
"column": 10
}
]
}
]
}
How can I resolve these issues?
回答1:
That because you don't have argument limit in on field umdHub.
To resolve, let's check your schema, on the umdHub field of type Query, and add limit arguments, then restart your server.
Exemple:
type Query {
umdHub(limit: Int, sort: SortInput) { // <-- Add this
articles
}
}
回答2:
Turns out this was the way to do it:
{
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
}
}
}
}
来源:https://stackoverflow.com/questions/55930539/normal-graphql-queries-causing-errors