March 2018
Intermediate to advanced
304 pages
6h 59m
English
Represents one of a finite set of possible values. GraphQL enums are not references for a numeric value, but are unique values in their own right. They serialize as a string: the name of the represented value.
enum
In an Absinthe schema, defining the enum and the internal representation it will map to:
| | @desc "The selected color channel" |
| | enum :color_channel do |
| | |
| | @desc "Red Color Channel" |
| | value :red, as: :r |
| | |
| | @desc "Green Color Channel" |
| | value :green, as: :g |
| | |
| | @desc "Blue Color Channel" |
| | value :blue, as: :b |
| | |
| | # Other values |
| | end |
There is also a shorthand values option available, if default settings are appropriate:
| | enum :color_channel, values: [ ... |
Read now
Unlock full access