Class: GraphQL::ObjectType
- Defined in:
- lib/graphql/object_type.rb
Overview
This type exposes fields on an object.
Direct Known Subclasses
Defined Under Namespace
Classes: UnresolvedTypeError
Instance Method Summary collapse
-
#all_fields ⇒ Array<GraphQL::Field>
All fields, including ones inherited from interfaces.
-
#fields ⇒ Hash<String => GraphQL::Field>
Map String fieldnames to their Field implementations.
-
#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.
- #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
#definition_proc=, included, #metadata
Methods included from Define::NonNullWithBang
Constructor Details
#initialize ⇒ ObjectType
Returns a new instance of ObjectType.
29 30 31 32 |
# File 'lib/graphql/object_type.rb', line 29 def initialize @fields = {} @dirty_interfaces = [] end |
Instance Method Details
#all_fields ⇒ Array<GraphQL::Field>
Returns All fields, including ones inherited from interfaces.
59 60 61 |
# File 'lib/graphql/object_type.rb', line 59 def all_fields interface_fields.merge(self.fields).values end |
#fields ⇒ Hash<String => GraphQL::Field>
Returns Map String fieldnames to their Field implementations.
27 |
# File 'lib/graphql/object_type.rb', line 27 lazy_defined_attr_accessor :fields |
#get_field(field_name) ⇒ GraphQL::Field
Returns The field definition for ‘field_name` (may be inherited from interfaces).
54 55 56 |
# File 'lib/graphql/object_type.rb', line 54 def get_field(field_name) fields[field_name] || interface_fields[field_name] end |
#interfaces ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/graphql/object_type.rb', line 40 def interfaces @clean_interfaces ||= begin ensure_defined @dirty_interfaces.map { |i_type| GraphQL::BaseType.(i_type) } rescue @dirty_interfaces end end |
#interfaces=(new_interfaces) ⇒ Object
35 36 37 38 |
# File 'lib/graphql/object_type.rb', line 35 def interfaces=(new_interfaces) @clean_interfaces = nil @dirty_interfaces = new_interfaces end |