Class: GraphQL::Schema::Enum
- Extended by:
- Forwardable, Member::AcceptsDefinition
- Defined in:
- lib/graphql/schema/enum.rb
Direct Known Subclasses
Introspection::DirectiveLocationEnum, Introspection::TypeKindEnum
Constant Summary
Constants included from Member::GraphQLTypeNames
Member::GraphQLTypeNames::Boolean, Member::GraphQLTypeNames::ID, Member::GraphQLTypeNames::Int
Class Method Summary collapse
-
.enum_value_class(new_enum_value_class = nil) ⇒ Class
For handling
value(...)
inputs and buildingGraphQL::Enum::EnumValue
s out of them. -
.kind ⇒ Object
-
.to_graphql ⇒ GraphQL::EnumType
-
.value(*args, **kwargs, &block) ⇒ void
Define a value for this enum.
-
.values ⇒ Hash<String => GraphQL::Schema::Enum::Value>
Possible values of this enum, keyed by name.
Methods included from Member::TypeSystemHelpers
#kind, #list?, #non_null?, #to_list_type, #to_non_null_type
Methods included from Member::BaseDSLMethods
#description, #graphql_name, #introspection, #mutation, #name, #overridden_graphql_name, #to_graphql, #unwrap
Methods included from Relay::TypeExtensions
#connection_type, #define_connection, #define_edge, #edge_type
Methods included from Member::CachedGraphQLDefinition
#graphql_definition, #initialize_copy
Class Method Details
.enum_value_class(new_enum_value_class = nil) ⇒ Class
Returns for handling value(...)
inputs and building GraphQL::Enum::EnumValue
s out of them
64 65 66 67 68 69 |
# File 'lib/graphql/schema/enum.rb', line 64 def enum_value_class(new_enum_value_class = nil) if new_enum_value_class @enum_value_class = new_enum_value_class end @enum_value_class || (superclass <= GraphQL::Schema::Enum ? superclass.enum_value_class : nil) end |
.kind ⇒ Object
71 72 73 |
# File 'lib/graphql/schema/enum.rb', line 71 def kind GraphQL::TypeKinds::ENUM end |
.to_graphql ⇒ GraphQL::EnumType
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/graphql/schema/enum.rb', line 51 def to_graphql enum_type = GraphQL::EnumType.new enum_type.name = graphql_name enum_type.description = description enum_type.introspection = introspection values.each do |name, val| enum_type.add_value(val.to_graphql) end enum_type.[:type_class] = self enum_type end |
.value(*args, **kwargs, &block) ⇒ void
This method returns an undefined value.
Define a value for this enum
36 37 38 39 40 41 |
# File 'lib/graphql/schema/enum.rb', line 36 def value(*args, **kwargs, &block) kwargs[:owner] = self value = enum_value_class.new(*args, **kwargs, &block) own_values[value.graphql_name] = value nil end |
.values ⇒ Hash<String => GraphQL::Schema::Enum::Value>
Returns Possible values of this enum, keyed by name
44 45 46 47 48 |
# File 'lib/graphql/schema/enum.rb', line 44 def values inherited_values = superclass <= GraphQL::Schema::Enum ? superclass.values : {} # Local values take precedence over inherited ones inherited_values.merge(own_values) end |