Reputation: 81
I was trying to create an enum type with Int value in GraphQL schema but failed. I might miss something in the doc. Anyone has any idea about how to implement Int value in the enum type like below?
enum IntValue {
1
2
3
}
Upvotes: 7
Views: 3777
Reputation: 158847
You could declare something like
enum IntValue { _1 _2 _3 }
enum IntName { ONE TWO THREE }
but in both cases those enumerated values would be different from the numbers 1
, 2
, 3
.
You can't declare something that looks like an enum but contains actual numbers. In the specification, an EnumTypeDefinition contains a list of EnumValueDefinition, each of which contains a single EnumValue; each value is
Name but not
true
orfalse
ornull
and finally a Name must begin with an underscore or a ASCII letter.
Upvotes: 4