Class: GraphQL::InterfaceType

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

Instance Attribute Summary collapse

Attributes inherited from BaseType

#ast_node, #default_relay, #default_scalar, #description, #introspection, #name

Instance Method Summary collapse

Methods inherited from BaseType

#==, #coerce_input, #coerce_isolated_input, #coerce_isolated_result, #coerce_result, #default_relay?, #default_scalar?, #introspection?, #list?, #non_null?, resolve_related_type, #to_definition, #to_list_type, #to_non_null_type, #to_s, #type_class, #unwrap, #valid_input?, #valid_isolated_input?, #validate_input, #validate_isolated_input

Methods included from Relay::TypeExtensions

#connection_type, #define_connection, #define_edge, #edge_type

Methods included from Define::InstanceDefinable

#define, #metadata, #redefine

Methods included from Define::NonNullWithBang

#!

Constructor Details

#initializeInterfaceType

Returns a new instance of InterfaceType.



11
12
13
14
15
16
# File 'lib/graphql/interface_type.rb', line 11

def initialize
  super
  @fields = {}
  @orphan_types = []
  @resolve_type_proc = nil
end

Instance Attribute Details

#fieldsObject



7
8
9
# File 'lib/graphql/interface_type.rb', line 7

def fields
  @fields
end

#orphan_typesObject



7
8
9
# File 'lib/graphql/interface_type.rb', line 7

def orphan_types
  @orphan_types
end

#resolve_type_procObject



7
8
9
# File 'lib/graphql/interface_type.rb', line 7

def resolve_type_proc
  @resolve_type_proc
end

#type_membership_classObject



66
67
68
# File 'lib/graphql/interface_type.rb', line 66

def type_membership_class
  @type_membership_class || GraphQL::Schema::TypeMembership
end

Instance Method Details

#all_fieldsArray<GraphQL::Field>

These fields don’t have instrumenation applied

Returns:

See Also:

  • Get fields with instrumentation


44
45
46
# File 'lib/graphql/interface_type.rb', line 44

def all_fields
  fields.values
end

#get_field(field_name) ⇒ GraphQL::Field

Returns The defined field for field_name.

Returns:



37
38
39
# File 'lib/graphql/interface_type.rb', line 37

def get_field(field_name)
  fields[field_name]
end

#get_possible_type(type_name, ctx) ⇒ GraphQL::ObjectType?

Get a possible type of this GraphQL::InterfaceType by type name

Parameters:

Returns:



52
53
54
55
# File 'lib/graphql/interface_type.rb', line 52

def get_possible_type(type_name, ctx)
  type = ctx.query.get_type(type_name)
  type if type && ctx.query.warden.possible_types(self).include?(type)
end

#initialize_copy(other) ⇒ Object



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

def initialize_copy(other)
  super
  @fields = other.fields.dup
  @orphan_types = other.orphan_types.dup
end

#kindObject



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

def kind
  GraphQL::TypeKinds::INTERFACE
end

#possible_type?(type, ctx) ⇒ Boolean

Check if a type is a possible type of this GraphQL::InterfaceType

Parameters:

Returns:



61
62
63
64
# File 'lib/graphql/interface_type.rb', line 61

def possible_type?(type, ctx)
  type_name = type.is_a?(String) ? type : type.graphql_name
  !get_possible_type(type_name, ctx).nil?
end

#resolve_type(value, ctx) ⇒ Object



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

def resolve_type(value, ctx)
  ctx.query.resolve_type(self, value)
end

#resolve_type=(resolve_type_callable) ⇒ Object



32
33
34
# File 'lib/graphql/interface_type.rb', line 32

def resolve_type=(resolve_type_callable)
  @resolve_type_proc = resolve_type_callable
end