【问题标题】:Sending an array of objects to GraphQL将对象数组发送到 GraphQL
【发布时间】:2018-11-21 05:04:46
【问题描述】:

我正在尝试将一组对象从 React 应用程序提供给 GraphQL。但是我收到了这个错误:

   Error: The type of Mutation.reorderFields(fieldsOrder:) must be Input Type but got: [orderField].

这是我的架构:

  reorderFields(
    fieldsOrder:[orderField]
  ):Boolean!

变异:

  type orderField{
    order: Int,
    myform: String,
    id: String,
  }

任何帮助将不胜感激,谢谢。

【问题讨论】:

  • 但这不是说orderField的类型应该是boolean,还是我读错了?
  • @JaakkoKarhu :Boolean 是 reaorderFields() 的返回类型而不是输入类型。

标签: javascript graphql graphql-js


【解决方案1】:

我相信问题可能出在 GraphQL 服务器上。 因为您的 orderField 被定义为对象类型,它可能应该被定义为输入类型。

在 GraphQL 变异中,数据负载需要定义为输入类型。

查看Mutations and Input Types 以获得有关如何进行突变的更好描述。

【讨论】:

    猜你喜欢
    • 2017-03-10
    • 1970-01-01
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-14
    • 2018-08-07
    相关资源
    最近更新 更多