Class: GraphQL::InterfaceType
- Defined in:
- lib/graphql/interface_type.rb
Overview
An Interface contains a collection of types which implement some of the same fields.
Interfaces can have fields, defined with field
, just like an object type.
Objects which implement this field inherit field definitions from the interface. An object type can override the inherited definition by redefining that field.
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
Attributes inherited from BaseType
Instance Method Summary collapse
-
#all_fields ⇒ Array<GraphQL::Field>
All fields on this type.
-
#get_field(field_name) ⇒ GraphQL::Field
The defined field for
field_name
. -
#initialize ⇒ InterfaceType
constructor
A new instance of InterfaceType.
- #initialize_copy(other) ⇒ 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 ⇒ InterfaceType
Returns a new instance of InterfaceType.
31 32 33 |
# File 'lib/graphql/interface_type.rb', line 31 def initialize @fields = {} end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
28 29 30 |
# File 'lib/graphql/interface_type.rb', line 28 def fields @fields end |
Instance Method Details
#all_fields ⇒ Array<GraphQL::Field>
Returns All fields on this type.
50 51 52 |
# File 'lib/graphql/interface_type.rb', line 50 def all_fields fields.values end |
#get_field(field_name) ⇒ GraphQL::Field
Returns The defined field for field_name
.
45 46 47 |
# File 'lib/graphql/interface_type.rb', line 45 def get_field(field_name) fields[field_name] end |
#initialize_copy(other) ⇒ Object
35 36 37 38 |
# File 'lib/graphql/interface_type.rb', line 35 def initialize_copy(other) super @fields = other.fields.dup end |