Class: GraphQL::InterfaceType

Inherits:
BaseType
  • Object
show all
Includes:
BaseType::HasPossibleTypes
Defined in:
lib/graphql/interface_type.rb

Overview

A collection of types which implement the same fields

Examples:

An interface with three required fields

DeviceInterface = GraphQL::InterfaceType.define do
  name("Device")
  description("Hardware devices for computing")

  field :ram, types.String
  field :processor, ProcessorType
  field :release_year, types.Int
end

Constant Summary

Constants included from BaseType::HasPossibleTypes

BaseType::HasPossibleTypes::DEFAULT_RESOLVE_TYPE

Instance Method Summary collapse

Methods included from BaseType::HasPossibleTypes

#resolve_type, #resolve_type=

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

#initializeInterfaceType

Returns a new instance of InterfaceType.



20
21
22
# File 'lib/graphql/interface_type.rb', line 20

def initialize
  @fields = {}
end

Instance Method Details

#all_fieldsArray<GraphQL::Field>

Returns All fields on this type.

Returns:



34
35
36
# File 'lib/graphql/interface_type.rb', line 34

def all_fields
  fields.values
end

#get_field(field_name) ⇒ GraphQL::Field

Returns The defined field for ‘field_name`.

Returns:



29
30
31
# File 'lib/graphql/interface_type.rb', line 29

def get_field(field_name)
  fields[field_name]
end

#kindObject



24
25
26
# File 'lib/graphql/interface_type.rb', line 24

def kind
  GraphQL::TypeKinds::INTERFACE
end