Class: GraphQL::Schema::EnumValue
- Includes:
- Member::AcceptsDefinition, Member::HasPath
- Defined in:
- lib/graphql/schema/enum_value.rb
Overview
A possible value for an Enum.
You can extend this class to customize enum values in your schema.
Constant Summary
Constants included from Member::GraphQLTypeNames
Member::GraphQLTypeNames::Boolean, Member::GraphQLTypeNames::ID, Member::GraphQLTypeNames::Int
Instance Attribute Summary collapse
-
#deprecation_reason ⇒ String
Explains why this value was deprecated (if present, this will be marked deprecated in introspection).
-
#graphql_name ⇒ Object
readonly
Returns the value of attribute graphql_name.
-
#owner ⇒ Class
readonly
The enum type that owns this value.
Instance Method Summary collapse
- #accessible?(_ctx) ⇒ Boolean
- #authorized?(_ctx) ⇒ Boolean
- #description(new_desc = nil) ⇒ Object
-
#initialize(graphql_name, desc = nil, owner:, description: nil, value: nil, deprecation_reason: nil, &block) ⇒ EnumValue
constructor
A new instance of EnumValue.
-
#to_graphql ⇒ GraphQL::EnumType::EnumValue
A runtime-ready object derived from this object.
- #value(new_val = nil) ⇒ Object
- #visible?(_ctx) ⇒ Boolean
Methods included from Member::HasPath
Methods included from Member::CachedGraphQLDefinition
#graphql_definition, #initialize_copy
Methods included from Relay::TypeExtensions
#connection_type, #define_connection, #define_edge, #edge_type
Methods included from Member::BaseDSLMethods
#default_graphql_name, #introspection, #mutation, #name, #overridden_graphql_name
Methods included from Member::TypeSystemHelpers
#kind, #list?, #non_null?, #to_list_type, #to_non_null_type, #to_type_signature
Methods included from Member::Scoped
Methods included from Member::RelayShortcuts
#connection_type, #connection_type_class, #edge_type, #edge_type_class
Constructor Details
#initialize(graphql_name, desc = nil, owner:, description: nil, value: nil, deprecation_reason: nil, &block) ⇒ EnumValue
Returns a new instance of EnumValue.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/graphql/schema/enum_value.rb', line 40 def initialize(graphql_name, desc = nil, owner:, description: nil, value: nil, deprecation_reason: nil, &block) @graphql_name = graphql_name.to_s @description = desc || description @value = value || @graphql_name @deprecation_reason = deprecation_reason @owner = owner if block_given? instance_eval(&block) end end |
Instance Attribute Details
#deprecation_reason ⇒ String
Returns Explains why this value was deprecated (if present, this will be marked deprecated in introspection).
38 39 40 |
# File 'lib/graphql/schema/enum_value.rb', line 38 def deprecation_reason @deprecation_reason end |
#graphql_name ⇒ Object (readonly)
Returns the value of attribute graphql_name.
32 33 34 |
# File 'lib/graphql/schema/enum_value.rb', line 32 def graphql_name @graphql_name end |
#owner ⇒ Class (readonly)
Returns The enum type that owns this value.
35 36 37 |
# File 'lib/graphql/schema/enum_value.rb', line 35 def owner @owner end |
Instance Method Details
#accessible?(_ctx) ⇒ Boolean
78 |
# File 'lib/graphql/schema/enum_value.rb', line 78 def accessible?(_ctx); true; end |
#authorized?(_ctx) ⇒ Boolean
79 |
# File 'lib/graphql/schema/enum_value.rb', line 79 def (_ctx); true; end |
#description(new_desc = nil) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/graphql/schema/enum_value.rb', line 52 def description(new_desc = nil) if new_desc @description = new_desc end @description end |
#to_graphql ⇒ GraphQL::EnumType::EnumValue
Returns A runtime-ready object derived from this object.
67 68 69 70 71 72 73 74 75 |
# File 'lib/graphql/schema/enum_value.rb', line 67 def to_graphql enum_value = GraphQL::EnumType::EnumValue.new enum_value.name = @graphql_name enum_value.description = @description enum_value.value = @value enum_value.deprecation_reason = @deprecation_reason enum_value.[:type_class] = self enum_value end |
#value(new_val = nil) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/graphql/schema/enum_value.rb', line 59 def value(new_val = nil) if new_val @value = new_val end @value end |
#visible?(_ctx) ⇒ Boolean
77 |
# File 'lib/graphql/schema/enum_value.rb', line 77 def visible?(_ctx); true; end |