【发布时间】:2019-07-31 23:18:05
【问题描述】:
我为我的对象创建了一个枚举类型
const MonthType = new GraphQLEnumType({
name: 'monthType',
value: {
JANUARY:{
value: "January"
},
FEBRUARY: {
value: 'February'
},
MARCH: {
value: 'March'
},
MAY: {
value: 'May'
},
JUNE: {
value: 'June'
},
JULY: {
value: 'July'
},
AUGUST: {
value: "August"
},
SEPTEMBER: {
value: 'September'
},
OCTOBER: {
value: 'October'
},
NOVEMEBER: {
value: 'November'
},
DECEMBER: {
value: 'December'
}
}
})
我在我的对象类型中使用类似这样的类型
const UserType = new GraphQLObjectType({
name: 'User', // Importance of Name here
fields: () => ({
id: {
type: GraphQLInt
},
userId: {
type: GraphQLInt
},
gradMonth: {
type: MonthType
},
现在,每当我启动我的快递服务器时,我的代码中都会出现以下错误
monthType 值必须是一个以值名作为键的对象
我打算做什么?我希望用户选择,传递应该是其中之一的月份的值。
有人可以帮我弄清楚为什么会出现以下错误吗?
【问题讨论】:
标签: node.js express graph graphql