Class: GraphQL::Schema::EnumValue
- Includes:
- Member::AcceptsDefinition, Member::CachedGraphQLDefinition, Member::CachedGraphQLDefinition::DeprecatedToGraphQL, Member::HasAstNode, Member::HasDeprecationReason, Member::HasDirectives, 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::HasDirectives
Member::HasDirectives::NO_DIRECTIVES
Constants included from Member::GraphQLTypeNames
Member::GraphQLTypeNames::Boolean, Member::GraphQLTypeNames::ID, Member::GraphQLTypeNames::Int
Instance Attribute Summary collapse
- 
  
    
      #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:, ast_node: nil, directives: nil, description: nil, value: nil, deprecation_reason: nil, &block)  ⇒ EnumValue 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of EnumValue. 
- 
  
    
      #inspect  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
- 
  
    
      #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::HasDeprecationReason
#deprecation_reason, #deprecation_reason=
Methods included from Member::HasDirectives
#directive, #directives, #remove_directive
Methods included from Member::HasAstNode
Methods included from Member::HasPath
Methods included from Member::CachedGraphQLDefinition
#deprecated_to_graphql, #graphql_definition, #initialize_copy, #type_class
Methods included from Relay::TypeExtensions
#connection_type, #define_connection, #define_edge, #edge_type
Methods included from Member::BaseDSLMethods
#default_graphql_name, #introspection, #introspection?, #mutation, #name, #overridden_graphql_name
Methods included from Member::BaseDSLMethods::ConfigurationExtension
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:, ast_node: nil, directives: nil, description: nil, value: nil, deprecation_reason: nil, &block) ⇒ EnumValue
Returns a new instance of EnumValue.
| 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # File 'lib/graphql/schema/enum_value.rb', line 41 def initialize(graphql_name, desc = nil, owner:, ast_node: nil, directives: nil, description: nil, value: nil, deprecation_reason: nil, &block) @graphql_name = graphql_name.to_s GraphQL::NameValidator.validate!(@graphql_name) @description = desc || description @value = value.nil? ? @graphql_name : value if deprecation_reason self.deprecation_reason = deprecation_reason end @owner = owner @ast_node = ast_node if directives directives.each do |dir_class, | directive(dir_class, **) end end if block_given? instance_eval(&block) end end | 
Instance Attribute Details
#graphql_name ⇒ Object (readonly)
Returns the value of attribute graphql_name.
| 36 37 38 | # File 'lib/graphql/schema/enum_value.rb', line 36 def graphql_name @graphql_name end | 
#owner ⇒ Class (readonly)
Returns The enum type that owns this value.
| 39 40 41 | # File 'lib/graphql/schema/enum_value.rb', line 39 def owner @owner end | 
Instance Method Details
#accessible?(_ctx) ⇒ Boolean
| 95 | # File 'lib/graphql/schema/enum_value.rb', line 95 def accessible?(_ctx); true; end | 
#authorized?(_ctx) ⇒ Boolean
| 96 | # File 'lib/graphql/schema/enum_value.rb', line 96 def (_ctx); true; end | 
#description(new_desc = nil) ⇒ Object
| 62 63 64 65 66 67 | # File 'lib/graphql/schema/enum_value.rb', line 62 def description(new_desc = nil) if new_desc @description = new_desc end @description end | 
#inspect ⇒ Object
| 90 91 92 | # File 'lib/graphql/schema/enum_value.rb', line 90 def inspect "#<#{self.class} #{path} @value=#{@value.inspect}#{description ? " @description=#{description.inspect}" : ""}>" end | 
#to_graphql ⇒ GraphQL::EnumType::EnumValue
Returns A runtime-ready object derived from this object.
| 79 80 81 82 83 84 85 86 87 88 | # File 'lib/graphql/schema/enum_value.rb', line 79 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 = self.deprecation_reason enum_value.[:type_class] = self enum_value.ast_node = ast_node enum_value end | 
#value(new_val = nil) ⇒ Object
| 69 70 71 72 73 74 | # File 'lib/graphql/schema/enum_value.rb', line 69 def value(new_val = nil) unless new_val.nil? @value = new_val end @value end | 
#visible?(_ctx) ⇒ Boolean
| 94 | # File 'lib/graphql/schema/enum_value.rb', line 94 def visible?(_ctx); true; end |