【问题标题】:GraphQL mutation issueGraphQL 突变问题
【发布时间】:2019-05-29 20:54:47
【问题描述】:

我是 GraphQL 的新手。我正在学习 GraphQL。

我的输入如下所示

mutation {
  createEvent:{eventInput: {title: "A Test", description:"Does this work?", price:9.99, date:"2018-12-06T09:26:30.645Z"}
    }
}

我收到如下错误

{
  "errors": [
    {
      "message": "Syntax Error: Expected Name, found {",
      "locations": [
        {
          "line": 2,
          "column": 15
        }
      ]
    }
  ]
}

【问题讨论】:

    标签: graphql


    【解决方案1】:

    好吧,我相信您的 createEvent 突变应该返回一个对象类型。对于 object type ,您必须为此 Mutation 指定至少一个来自返回类型的字段。

    应该是:

    mutation {
      createEvent(eventInput: {
            title: "A Test" 
            description:"Does this work?"
            price:9.99
            date:"2018-12-06T09:26:30.645Z"
        }){
            someFieldInTheReturnType
        }
    }
    

    【讨论】:

    • 很高兴听到。如果您接受我的回答并投票给我会更好:D
    猜你喜欢
    • 2020-07-03
    • 2019-01-23
    • 2021-03-09
    • 2020-02-18
    • 2019-06-18
    • 2018-06-20
    • 2019-07-26
    • 2019-08-24
    • 1970-01-01
    相关资源
    最近更新 更多