Enum

Description

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.

Absinthe Macro

enum

Examples

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:​ [​:red​, ​:green​, ​:blue​]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.186.178