1

I am trying to add graphql input object type inside another graphl input object type.

In the longer run i happen to have complex input types nested in each other, rather than plain GraphqlJSON objects (which i really want to avoid)

it gives the following error

{
  "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 }
    })
});
Amaar Hassan
  • 338
  • 2
  • 7
  • 1
    There's nothing visible wrong with that code. However, I've seen that specific error message before when dealing with circular references. Are these input types in their own files and being imported? – Daniel Rearden Apr 26 '19 at 12:23

0 Answers0