【发布时间】:2020-06-14 07:30:18
【问题描述】:
我的数据库中有一个地址,我已将其放入location 哈希中。哈希包含 streetAddress、city、state 和 zipCode 的单独键。我已经在我的 graphql 模式文件中嵌套了这样的数据:
location: {
streetAddress: {
type: String,
required: true,
unqiue: true
},
city: {
type: String,
required: true
},
state: {
type: String,
required: true
},
zipCode: {
type: Number,
required: true
}
}
我已经实现了这样的架构类型:
fields: () => ({
id: { type: GraphQLID },
name: { type: GraphQLString },
id: {type: GraphQLID},
phoneNum: { type: GraphQLString },
location: {
streetAddress: { type: GraphQLString },
city: { type: GraphQLString },
state: { type: GraphQLString },
zipCode: { type: GraphQLInt }
}
...
但是,当我尝试在 graphql 中进行查询时,我收到一条错误消息,指出输出类型未定义:
"message": "The type of RestaurantType.location must be Output Type but got: undefined."
我相信我了解错误的来源;我假设它期望location 也有一个类型。执行此操作/修复此错误消息的正确语法是什么?
【问题讨论】:
标签: graphql