Class: GraphQL::ObjectType
- Defined in:
- lib/graphql/object_type.rb
Overview
This type exposes fields on an object.
Defined Under Namespace
Classes: UnresolvedTypeError
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#fields ⇒ Hash<String, GraphQL::Field>
Map String fieldnames to their Field implementations.
-
#interfaces ⇒ Object
Returns the value of attribute interfaces.
-
#name ⇒ Object
Returns the value of attribute name.
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.
- #kind ⇒ Object
Methods inherited from BaseType
#==, #coerce_input, #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.
30 31 32 33 |
# File 'lib/graphql/object_type.rb', line 30 def initialize @fields = {} @interfaces = [] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
25 26 27 |
# File 'lib/graphql/object_type.rb', line 25 def description @description end |
#fields ⇒ Hash<String, GraphQL::Field>
Returns Map String fieldnames to their Field implementations.
28 29 30 |
# File 'lib/graphql/object_type.rb', line 28 def fields @fields end |
#interfaces ⇒ Object
Returns the value of attribute interfaces.
25 26 27 |
# File 'lib/graphql/object_type.rb', line 25 def interfaces @interfaces end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/graphql/object_type.rb', line 25 def name @name end |
Instance Method Details
#all_fields ⇒ Array<GraphQL::Field>
Returns All fields, including ones inherited from interfaces.
50 51 52 |
# File 'lib/graphql/object_type.rb', line 50 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).
45 46 47 |
# File 'lib/graphql/object_type.rb', line 45 def get_field(field_name) fields[field_name] || interface_fields[field_name] end |