/
Enums
To view this content, buy the book! 😃🙏
Or if you’ve already purchased.
Enums
When a scalar field has a small set of possible values, it’s best to use an enum instead. The enum type declaration lists all the options:
enum Direction {
NORTH
EAST
SOUTH
WEST
}
Enums are usually serialized as strings (for example, "NORTH"
). Here’s an example Query type, query operation, and response:
type Query {
currentHeading(flightId: ID): Direction
}
query {
currentHeading(flightId: "abc")
}
{
"data": {
"currentHeading": "NORTH"
}
}