Class: GraphQL::EnumType
Overview
A finite set of possible values, represented in query strings with SCREAMING_CASE_NAMES
Defined Under Namespace
Classes: EnumValue
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#coerce_non_null_input(value_name) ⇒ Object
Get the underlying value for this enum value.
- #coerce_result(value) ⇒ Object
- #kind ⇒ Object
- #to_s ⇒ Object
- #valid_non_null_input?(value_name) ⇒ Boolean
-
#value(name, description = nil, deprecation_reason: nil, value: name) ⇒ Object
deprecated
Deprecated.
use define API instead
Methods inherited from BaseType
#==, #coerce_input, #resolve_type, #to_list_type, #to_non_null_type, #unwrap, #valid_input?
Methods included from DefinitionHelpers::DefinedByConfig
Methods included from DefinitionHelpers::NonNullWithBang
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
14 15 16 |
# File 'lib/graphql/enum_type.rb', line 14 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/graphql/enum_type.rb', line 14 def name @name end |
#values ⇒ Object
Returns the value of attribute values.
14 15 16 |
# File 'lib/graphql/enum_type.rb', line 14 def values @values end |
Instance Method Details
#coerce_non_null_input(value_name) ⇒ Object
Get the underlying value for this enum value
56 57 58 |
# File 'lib/graphql/enum_type.rb', line 56 def coerce_non_null_input(value_name) @values_by_name.fetch(value_name).value end |
#coerce_result(value) ⇒ Object
60 61 62 |
# File 'lib/graphql/enum_type.rb', line 60 def coerce_result(value) @values_by_value.fetch(value).name end |
#kind ⇒ Object
40 41 42 |
# File 'lib/graphql/enum_type.rb', line 40 def kind GraphQL::TypeKinds::ENUM end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/graphql/enum_type.rb', line 64 def to_s name end |
#valid_non_null_input?(value_name) ⇒ Boolean
44 45 46 |
# File 'lib/graphql/enum_type.rb', line 44 def valid_non_null_input?(value_name) @values_by_name.key?(value_name) end |
#value(name, description = nil, deprecation_reason: nil, value: name) ⇒ Object
Deprecated.
use define API instead
Define a value within this enum
36 37 38 |
# File 'lib/graphql/enum_type.rb', line 36 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 |