例如:http://localhost:1337/graphql?query={users(id:1){id}}期望:
{
"data": {
"users": [
{
"id": "1"
}
]
}
}实际:
{
"errors": [
{
"message": "Unknown argument \"id\" on field \"users\" of type \"Schema\".",
"locations": [
{
"line": 1,
"column": 8
}
]
}
]
}发布于 2018-06-19 18:08:35
使用strapi v3.0.0-alpha.12.4,您应该指定"where“参数来过滤数据。
在您的情况下,它应该是:
http://localhost:1337/graphql?query={users(where:{id:1}){id}}来自官方文档(https://strapi.io/documentation/3.x.x/guides/graphql.html):
您还可以将不同的参数应用于查询,以进行更复杂的查询。
limit (整型):定义返回条目的数量。
start (整数):定义要跳过的条目数量。
sort (string):定义数据的排序方式。
where (对象):定义要在查询中应用的过滤器。
:等于。
_ne:不等于。
_lt:低于。
_lte:小于或等于。
_gt:大于。
_gte:小于或等于。
_contains:包含。
_containss:包含敏感的。
发布于 2018-05-13 23:29:30
我认为您需要查询_id,而不是id
https://stackoverflow.com/questions/47928923
复制相似问题