Class: GraphQL::ObjectType
- Defined in:
- lib/graphql/object_type.rb
Overview
This type exposes fields on an object.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fields ⇒ Hash<String => GraphQL::Field>
Map String fieldnames to their Field implementations.
-
#mutation ⇒ GraphQL::Relay::Mutation?
The mutation this field was derived from, if it was derived from a mutation.
Attributes inherited from BaseType
Instance Method Summary collapse
-
#all_fields ⇒ Array<GraphQL::Field>
All fields, including ones inherited from interfaces.
-
#get_field(field_name) ⇒ GraphQL::Field
The field definition for
field_name
(may be inherited from interfaces). -
#initialize ⇒ ObjectType
constructor
A new instance of ObjectType.
- #initialize_copy(other) ⇒ Object
- #interfaces ⇒ Object
- #interfaces=(new_interfaces) ⇒ Object
- #kind ⇒ Object
Methods inherited from BaseType
#==, #coerce_input, #connection_type, #define_connection, #define_edge, #edge_type, resolve_related_type, #resolve_type, #to_list_type, #to_non_null_type, #to_s, #unwrap, #valid_input?, #validate_input
Methods included from Define::InstanceDefinable
Methods included from Define::NonNullWithBang
Constructor Details
#initialize ⇒ ObjectType
Returns a new instance of ObjectType.
37 38 39 40 |
# File 'lib/graphql/object_type.rb', line 37 def initialize @fields = {} @dirty_interfaces = [] end |
Instance Attribute Details
#fields ⇒ Hash<String => GraphQL::Field>
Returns Map String fieldnames to their Field implementations.
30 31 32 |
# File 'lib/graphql/object_type.rb', line 30 def fields @fields end |
#mutation ⇒ GraphQL::Relay::Mutation?
Returns The mutation this field was derived from, if it was derived from a mutation.
33 34 35 |
# File 'lib/graphql/object_type.rb', line 33 def mutation @mutation end |
Instance Method Details
#all_fields ⇒ Array<GraphQL::Field>
Returns All fields, including ones inherited from interfaces.
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
Returns The field definition for field_name
(may be inherited from interfaces).
70 71 72 |
# File 'lib/graphql/object_type.rb', line 70 def get_field(field_name) fields[field_name] || interface_fields[field_name] end |
#initialize_copy(other) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/graphql/object_type.rb', line 42 def initialize_copy(other) super @clean_interfaces = nil @dirty_interfaces = other.dirty_interfaces.dup @fields = other.fields.dup end |
#interfaces ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/graphql/object_type.rb', line 55 def interfaces @clean_interfaces ||= begin if @dirty_interfaces.respond_to?(:map) @dirty_interfaces.map { |i_type| GraphQL::BaseType.(i_type) } else @dirty_interfaces end end end |
#interfaces=(new_interfaces) ⇒ Object
50 51 52 53 |
# File 'lib/graphql/object_type.rb', line 50 def interfaces=(new_interfaces) @clean_interfaces = nil @dirty_interfaces = new_interfaces end |