简体   繁体   English

为什么graphQl在尝试切片查询时返回“Unknown argument 'first' on field...”错误?

[英]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.

相关问题 Graphql 字段上的未知参数 - Graphql Unknown argument on field 收到错误:类型为“查询” [GraphQL,Relay,React]的字段“用户”上的未知参数“ id” - Getting error : Unknown argument “id” on field “user” of type “Query” [GraphQL, Relay, React] GraphQL 查询中的错误显示未知类型“ContentfulSizes” - Error in GraphQL query it says Unknown type "ContentfulSizes" CombinedErrors graphQLErrors Unknown argument limit on field Query.posts - 尝试使用 urql、Strapi、Next JS 将参数传递给查询 - CombinedErrors graphQLErrors Unknown argument limit on field Query.posts - Trying to pass argument to query using urql, Strapi, Next JS GraphQL 查询返回错误“不能为不可为空的字段返回空值” - GraphQL query returns error "Cannot return null for non-nullable field" GraphQL查询返回错误.filter不是函数 - GraphQL Query returns error .filter is not a function Gatsby GraphQL 中用于自定义查询的未知字段错误 - Unknow field error in Gatsby GraphQL for custom query 获取内容时 graphql 查询中出现未知类型错误? - unknown type error in graphql query while fetching content? Gatsby Contentful - GraphQL 查询错误:未知类型“ContentfulFixed” - Gatsby Contentful - GraphQL query error: Unknown type "ContentfulFixed" 您的 GraphQL 查询中出现错误:无法在“StrapiPropiedadesImagen”类型上查询字段“childImageSharp” - There was an error in your GraphQL query: Cannot query field “childImageSharp” on type “StrapiPropiedadesImagen”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM