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.
-
#resolve_type_proc ⇒ Object
Returns the value of attribute resolve_type_proc.
Attributes inherited from BaseType
#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
The defined field for
field_name
. -
#initialize ⇒ InterfaceType
constructor
A new instance of InterfaceType.
- #initialize_copy(other) ⇒ Object
- #kind ⇒ Object
- #resolve_type(value, ctx) ⇒ Object
- #resolve_type=(resolve_type_callable) ⇒ Object
Methods inherited from BaseType
#==, #coerce_input, #coerce_isolated_input, #coerce_isolated_result, #coerce_result, #connection_type, #default_relay?, #default_scalar?, #define_connection, #define_edge, #edge_type, #introspection?, #list?, #non_null?, resolve_related_type, #to_definition, #to_list_type, #to_non_null_type, #to_s, #unwrap, #valid_input?, #valid_isolated_input?, #validate_input, #validate_isolated_input
Methods included from Define::InstanceDefinable
Methods included from Define::NonNullWithBang
Constructor Details
permalink #initialize ⇒ InterfaceType
Returns a new instance of InterfaceType.
31 32 33 34 35 |
# File 'lib/graphql/interface_type.rb', line 31 def initialize super @fields = {} @resolve_type_proc = nil end |
Instance Attribute Details
permalink #fields ⇒ Object
Returns the value of attribute fields.
28 29 30 |
# File 'lib/graphql/interface_type.rb', line 28 def fields @fields end |
permalink #resolve_type_proc ⇒ Object
Returns the value of attribute resolve_type_proc.
28 29 30 |
# File 'lib/graphql/interface_type.rb', line 28 def resolve_type_proc @resolve_type_proc end |
Instance Method Details
permalink #all_fields ⇒ Array<GraphQL::Field>
These fields don't have instrumenation applied
62 63 64 |
# File 'lib/graphql/interface_type.rb', line 62 def all_fields fields.values end |
permalink #get_field(field_name) ⇒ GraphQL::Field
Returns The defined field for field_name
.
55 56 57 |
# File 'lib/graphql/interface_type.rb', line 55 def get_field(field_name) fields[field_name] end |
permalink #initialize_copy(other) ⇒ Object
[View source]
37 38 39 40 |
# File 'lib/graphql/interface_type.rb', line 37 def initialize_copy(other) super @fields = other.fields.dup end |
permalink #kind ⇒ Object
[View source]
42 43 44 |
# File 'lib/graphql/interface_type.rb', line 42 def kind GraphQL::TypeKinds::INTERFACE end |
permalink #resolve_type(value, ctx) ⇒ Object
[View source]
46 47 48 |
# File 'lib/graphql/interface_type.rb', line 46 def resolve_type(value, ctx) ctx.query.resolve_type(self, value) end |
permalink #resolve_type=(resolve_type_callable) ⇒ Object
[View source]
50 51 52 |
# File 'lib/graphql/interface_type.rb', line 50 def resolve_type=(resolve_type_callable) @resolve_type_proc = resolve_type_callable end |