Reputation: 11830
I have created an enum type for my object
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'
}
}
})
which I am using kind of like this in my Object type
const UserType = new GraphQLObjectType({
name: 'User', // Importance of Name here
fields: () => ({
id: {
type: GraphQLInt
},
userId: {
type: GraphQLInt
},
gradMonth: {
type: MonthType
},
Now, Whenever I start my express server, I am thrown the following error in my code
monthType values must be an object with value names as keys
What I intend to do? I want the user to select, pass the value of the month which should be one of these.
Can someone help me in figuring out why I am getting the following error?
Upvotes: 0
Views: 401
Reputation: 4464
Try replacing value
by values
at the begining :
const MonthType = new GraphQLEnumType({
name: 'monthType',
values: { // <=== here
//...
Upvotes: 2