Reputation: 39
Ex: http://localhost:1337/graphql?query={users(id:1){id}} expect:
{
"data": {
"users": [
{
"id": "1"
}
]
}
}
actual:
{
"errors": [
{
"message": "Unknown argument \"id\" on field \"users\" of type \"Schema\".",
"locations": [
{
"line": 1,
"column": 8
}
]
}
]
}
Upvotes: 2
Views: 2241
Reputation: 63
Using strapi v3.0.0-alpha.12.4 you should specify "where" parameter to filter data.
In your case it should be:
http://localhost:1337/graphql?query={users(where:{id:1}){id}}
From the official documentation (https://strapi.io/documentation/3.x.x/guides/graphql.html):
You can also apply different parameters to the query to make more complex queries.
limit (integer): Define the number of returned entries.
start (integer): Define the amount of entries to skip.
sort (string): Define how the data should be sorted.
where (object): Define the filters to apply in the query.
: Equals.
_ne: Not equals.
_lt: Lower than.
_lte: Lower than or equal to.
_gt: Greater than.
_gte: Lower than or equal to.
_contains: Contains.
_containss: Contains sensitive.
Upvotes: 3