Class: GraphQL::ObjectType
- Extended by:
 - Define::InstanceDefinable::DeprecatedDefine
 
- Defined in:
 - lib/graphql/object_type.rb
 
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 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
 - 
  
    
      #structural_interface_type_memberships  ⇒ Object 
    
    
  
  
  
  
    
    
      writeonly
    
  
  
  
  
  
  
    
 
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, **options)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Declare that this object implements this interface.
 - 
  
    
      #initialize  ⇒ ObjectType 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ObjectType.
 - 
  
    
      #initialize_copy(other)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #interfaces(ctx = GraphQL::Query::NullContext)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #interfaces=(new_interfaces)  ⇒ Object 
    
    
  
  
  
  
  
  
  deprecated
  
  
    Deprecated. 
Use
implementsinstead ofinterfaces. - 
  
    
      #kind  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #resolve_type_proc  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 
Methods included from Define::InstanceDefinable::DeprecatedDefine
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, #type_class, #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
#define, #deprecated_define, #metadata, #redefine
Methods included from Define::NonNullWithBang
Constructor Details
#initialize ⇒ ObjectType
Returns a new instance of ObjectType.
      19 20 21 22 23 24 25  | 
    
      # File 'lib/graphql/object_type.rb', line 19 def initialize super @fields = {} @clean_inherited_fields = nil @structural_interface_type_memberships = [] @inherited_interface_type_memberships = [] end  | 
  
Instance Attribute Details
#fields ⇒ Hash<String => GraphQL::Field>
Returns Map String fieldnames to their Field implementations.
      13 14 15  | 
    
      # File 'lib/graphql/object_type.rb', line 13 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.
      19 20 21  | 
    
      # File 'lib/graphql/object_type.rb', line 19 def mutation @mutation end  | 
  
#relay_node_type ⇒ Object
      10 11 12  | 
    
      # File 'lib/graphql/object_type.rb', line 10 def relay_node_type @relay_node_type end  | 
  
#structural_interface_type_memberships=(value) ⇒ Object
      102 103 104  | 
    
      # File 'lib/graphql/object_type.rb', line 102 def structural_interface_type_memberships=(value) @structural_interface_type_memberships = value end  | 
  
Instance Method Details
#all_fields ⇒ Array<GraphQL::Field>
These fields don’t have instrumenation applied
      75 76 77  | 
    
      # File 'lib/graphql/object_type.rb', line 75 def all_fields interface_fields.merge(self.fields).values end  | 
  
#get_field(field_name) ⇒ GraphQL::Field
This fields doesnt have instrumenation applied
      68 69 70  | 
    
      # File 'lib/graphql/object_type.rb', line 68 def get_field(field_name) fields[field_name] || interface_fields[field_name] end  | 
  
#implements(interfaces, inherit: false, **options) ⇒ Object
Declare that this object implements this interface. This declaration will be validated when the schema is defined.
      83 84 85 86 87 88 89 90 91 92 93 94 95 96  | 
    
      # File 'lib/graphql/object_type.rb', line 83 def implements(interfaces, inherit: false, **) if !interfaces.is_a?(Array) raise ArgumentError, "`implements(interfaces)` must be an array, not #{interfaces.class} (#{interfaces})" end @clean_inherited_fields = nil type_memberships = inherit ? @inherited_interface_type_memberships : @structural_interface_type_memberships interfaces.each do |iface| iface = BaseType.(iface) if iface.is_a?(GraphQL::InterfaceType) type_memberships << iface.type_membership_class.new(iface, self, **) end end end  | 
  
#initialize_copy(other) ⇒ Object
      27 28 29 30 31 32  | 
    
      # File 'lib/graphql/object_type.rb', line 27 def initialize_copy(other) super @structural_interface_type_memberships = other.structural_interface_type_memberships.dup @inherited_interface_type_memberships = other.inherited_interface_type_memberships.dup @fields = other.fields.dup end  | 
  
#interfaces(ctx = GraphQL::Query::NullContext) ⇒ Object
      44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59  | 
    
      # File 'lib/graphql/object_type.rb', line 44 def interfaces(ctx = GraphQL::Query::NullContext) ensure_defined visible_ifaces = [] unfiltered = ctx == GraphQL::Query::NullContext [@structural_interface_type_memberships, @inherited_interface_type_memberships].each do |tms| tms.each do |type_membership| if unfiltered || type_membership.visible?(ctx) # if this is derived from a class-based object, we have to # get the `.graphql_definition` of the attached interface. visible_ifaces << GraphQL::BaseType.(type_membership.abstract_type) end end end visible_ifaces end  | 
  
#interfaces=(new_interfaces) ⇒ Object
Use implements instead of interfaces.
This method declares interfaces for this type AND inherits any field definitions
      37 38 39 40 41 42  | 
    
      # File 'lib/graphql/object_type.rb', line 37 def interfaces=(new_interfaces) @structural_interface_type_memberships = [] @inherited_interface_type_memberships = [] @clean_inherited_fields = nil implements(new_interfaces, inherit: true) end  | 
  
#kind ⇒ Object
      61 62 63  | 
    
      # File 'lib/graphql/object_type.rb', line 61 def kind GraphQL::TypeKinds::OBJECT end  | 
  
#resolve_type_proc ⇒ Object
      98 99 100  | 
    
      # File 'lib/graphql/object_type.rb', line 98 def resolve_type_proc nil end  |