[英]Why graphQl returns “Unknown argument 'first' on field…” error when trying to slice on query?
I am trying to fetch first five items of a set.我正在尝试获取一组的前五个项目。 My query is following:我的查询如下:
query sequence($id: String) {
sequence(id: $id) {
items(first:1) {
content
}
}
}
How ever, I get response然而,我得到了回应
"Unknown argument \\"first\\" on field \\"items\\" of type \\"Sequence\\"." “类型为“序列”的字段“项目”上的“未知参数”“第一个”。”
As far as I understood from the docs this is how I am supposed to make query if I want to get a limited amount of items back.据我从文档中了解到,如果我想取回有限数量的物品,我应该如何进行查询。
Do I need to define the argument somewhere in the schema?我需要在模式中的某处定义参数吗? How do I limit the amount of returned items properly?如何正确限制退货数量?
All field arguments need to be defined in the schema, the default behaviour is for a field to accept no arguments.所有字段参数都需要在架构中定义,默认行为是字段不接受任何参数。
You can define a first
argument in your items
field in your schema using syntax like this:您可以使用如下语法在架构的items
字段中定义first
参数:
type Sequence {
items(first: Int): [Item]
}
(See: Example No. 120 in the spec.) (参见:规范中的 第 120 号示例。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.