我正在尝试在另一个 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 }
})
});