嵌套Graphql输入对象类型

时间:2019-04-26 11:51:34

标签: graphql graphql-mutation

我正在尝试在另一个graphl输入对象类型内添加graphql输入对象类型。

从长远来看,我碰巧彼此之间嵌套了复杂的输入类型,而不是普通的GraphqlJSON对象(我真的想避免)

出现以下错误

{
  "data": {
    "createPlace": null
  },
  "errors": [
    {
      "message": "Cannot read property 'name' of undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createPlace"
      ]
    }
  ]
}
const LocationInputType = new GraphQLInputObjectType({
    name: 'LocationInput',
    fields: () => ({
        lat: { type: new GraphQLNonNull(GraphQLString) },
        lng: { type: new GraphQLNonNull(GraphQLString) }
    })
});


const CreatePlaceInputType = new GraphQLInputObjectType({
    name: 'CreatePlace',
    fields: () => ({
        name: { type: new GraphQLNonNull(GraphQLString) },
        avatar: { type: GraphQLString },
        location: { type: LocationInputType },
        schema: { type: GraphQLID }
    })
});

0 个答案:

没有答案
相关问题