Class: GraphQL::EnumType
- Inherits:
-
Object
- Object
- GraphQL::EnumType
- Extended by:
- DefinitionHelpers::Definable
- Includes:
- DefinitionHelpers::NonNullWithBang
- Defined in:
- lib/graph_ql/enum_type.rb
Overview
A finite set of possible values, represented in query strings with SCREAMING_CASE_NAMES
Defined Under Namespace
Classes: EnumValue
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#coerce(value_name) ⇒ Object
Get the underlying value for this enum value.
-
#initialize {|_self, GraphQL::DefinitionHelpers::TypeDefiner.instance, GraphQL::DefinitionHelpers::FieldDefiner.instance, GraphQL::DefinitionHelpers::ArgumentDefiner.instance| ... } ⇒ EnumType
constructor
A new instance of EnumType.
- #kind ⇒ Object
-
#value(name, description = nil, deprecation_reason: nil, value: name) ⇒ Object
Define a value within this enum.
Methods included from DefinitionHelpers::Definable
Methods included from DefinitionHelpers::NonNullWithBang
Constructor Details
#initialize {|_self, GraphQL::DefinitionHelpers::TypeDefiner.instance, GraphQL::DefinitionHelpers::FieldDefiner.instance, GraphQL::DefinitionHelpers::ArgumentDefiner.instance| ... } ⇒ EnumType
Returns a new instance of EnumType.
18 19 20 21 22 23 24 25 26 |
# File 'lib/graph_ql/enum_type.rb', line 18 def initialize @values = {} yield( self, GraphQL::DefinitionHelpers::TypeDefiner.instance, GraphQL::DefinitionHelpers::FieldDefiner.instance, GraphQL::DefinitionHelpers::ArgumentDefiner.instance ) end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
17 18 19 |
# File 'lib/graph_ql/enum_type.rb', line 17 def values @values end |
Instance Method Details
#coerce(value_name) ⇒ Object
Get the underlying value for this enum value
50 51 52 |
# File 'lib/graph_ql/enum_type.rb', line 50 def coerce(value_name) @values[value_name].value end |
#kind ⇒ Object
38 39 40 |
# File 'lib/graph_ql/enum_type.rb', line 38 def kind GraphQL::TypeKinds::ENUM end |
#value(name, description = nil, deprecation_reason: nil, value: name) ⇒ Object
Define a value within this enum
34 35 36 |
# File 'lib/graph_ql/enum_type.rb', line 34 def value(name, description=nil, deprecation_reason: nil, value: name) @values[name] = EnumValue.new(name: name, description: description, deprecation_reason: deprecation_reason, value: value) end |