Class: GraphQL::ObjectType
- Defined in:
 - lib/graphql/object_type.rb
 
Overview
This type exposes fields on an object.
Instance Attribute Summary collapse
- 
  
    
      #fields  ⇒ Hash<String => GraphQL::Field> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Map String fieldnames to their Field implementations.
 - 
  
    
      #mutation  ⇒ GraphQL::Relay::Mutation? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The mutation this object type was derived from, if it is an auto-generated payload type.
 - 
  
    
      #relay_node_type  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute relay_node_type.
 
Attributes inherited from BaseType
#ast_node, #default_relay, #default_scalar, #description, #introspection, #name
Instance Method Summary collapse
- 
  
    
      #all_fields  ⇒ Array<GraphQL::Field> 
    
    
  
  
  
  
  
  
  
  
  
    
These fields don’t have instrumenation applied.
 - 
  
    
      #get_field(field_name)  ⇒ GraphQL::Field 
    
    
  
  
  
  
  
  
  
  
  
    
This fields doesnt have instrumenation applied.
 - 
  
    
      #implements(interfaces, inherit: false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Declare that this object implements this interface.
 - 
  
    
      #initialize  ⇒ ObjectType 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ObjectType.
 - 
  
    
      #initialize_copy(other)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #interfaces  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #interfaces=(new_interfaces)  ⇒ Object 
    
    
  
  
  
  
  
  
  deprecated
  
  
    Deprecated. 
Use
implementsinstead ofinterfaces. - 
  
    
      #kind  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #resolve_type_proc  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 
Methods inherited from BaseType
#==, #coerce_input, #coerce_isolated_input, #coerce_isolated_result, #coerce_result, #default_relay?, #default_scalar?, #introspection?, #list?, #non_null?, resolve_related_type, #resolve_type, #to_definition, #to_list_type, #to_non_null_type, #to_s, #unwrap, #valid_input?, #valid_isolated_input?, #validate_input, #validate_isolated_input
Methods included from Relay::TypeExtensions
#connection_type, #define_connection, #define_edge, #edge_type
Methods included from Define::InstanceDefinable
Methods included from Define::NonNullWithBang
Constructor Details
#initialize ⇒ ObjectType
Returns a new instance of ObjectType
      37 38 39 40 41 42 43  | 
    
      # File 'lib/graphql/object_type.rb', line 37 def initialize super @fields = {} @interface_fields = {} @dirty_interfaces = [] @dirty_inherited_interfaces = [] end  | 
  
Instance Attribute Details
#fields ⇒ Hash<String => GraphQL::Field>
Returns Map String fieldnames to their Field implementations
      31 32 33  | 
    
      # File 'lib/graphql/object_type.rb', line 31 def fields @fields end  | 
  
#mutation ⇒ GraphQL::Relay::Mutation?
Returns The mutation this object type was derived from, if it is an auto-generated payload type.
      37 38 39  | 
    
      # File 'lib/graphql/object_type.rb', line 37 def mutation @mutation end  | 
  
#relay_node_type ⇒ Object
Returns the value of attribute relay_node_type
      28 29 30  | 
    
      # File 'lib/graphql/object_type.rb', line 28 def relay_node_type @relay_node_type end  | 
  
Instance Method Details
#all_fields ⇒ Array<GraphQL::Field>
These fields don’t have instrumenation applied
      86 87 88  | 
    
      # File 'lib/graphql/object_type.rb', line 86 def all_fields interface_fields.merge(self.fields).values end  | 
  
#get_field(field_name) ⇒ GraphQL::Field
This fields doesnt have instrumenation applied
      79 80 81  | 
    
      # File 'lib/graphql/object_type.rb', line 79 def get_field(field_name) fields[field_name] || interface_fields[field_name] end  | 
  
#implements(interfaces, inherit: false) ⇒ Object
Declare that this object implements this interface. This declaration will be validated when the schema is defined.
      94 95 96 97 98 99 100 101 102 103  | 
    
      # File 'lib/graphql/object_type.rb', line 94 def implements(interfaces, inherit: false) if !interfaces.is_a?(Array) raise ArgumentError, "`implements(interfaces)` must be an array, not #{interfaces.class} (#{interfaces})" end @clean_interfaces = nil @clean_inherited_fields = nil dirty_ifaces = inherit ? @dirty_inherited_interfaces : @dirty_interfaces dirty_ifaces.concat(interfaces) end  | 
  
#initialize_copy(other) ⇒ Object
      45 46 47 48 49 50 51 52  | 
    
      # File 'lib/graphql/object_type.rb', line 45 def initialize_copy(other) super @clean_interfaces = nil @clean_inherited_interfaces = nil @dirty_interfaces = other.dirty_interfaces.dup @dirty_inherited_interfaces = other.dirty_inherited_interfaces.dup @fields = other.fields.dup end  | 
  
#interfaces ⇒ Object
      67 68 69 70  | 
    
      # File 'lib/graphql/object_type.rb', line 67 def interfaces load_interfaces @clean_interfaces end  | 
  
#interfaces=(new_interfaces) ⇒ Object
Use implements instead of interfaces.
This method declares interfaces for this type AND inherits any field definitions
      57 58 59 60 61 62 63 64 65  | 
    
      # File 'lib/graphql/object_type.rb', line 57 def interfaces=(new_interfaces) @clean_interfaces = nil @clean_inherited_interfaces = nil @clean_inherited_fields = nil @dirty_inherited_interfaces = [] @dirty_inherited_fields = {} implements(new_interfaces, inherit: true) end  | 
  
#kind ⇒ Object
      72 73 74  | 
    
      # File 'lib/graphql/object_type.rb', line 72 def kind GraphQL::TypeKinds::OBJECT end  | 
  
#resolve_type_proc ⇒ Object
      105 106 107  | 
    
      # File 'lib/graphql/object_type.rb', line 105 def resolve_type_proc nil end  |