Does GraphQL take Int as enum
Asked Answered
G

1

7

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
}
Georginegeorglana answered 1/8, 2018 at 4:14 Comment(0)
F
4

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 or false or null

and finally a Name must begin with an underscore or a ASCII letter.

Firstnighter answered 1/8, 2018 at 4:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.