Class: GraphQL::UnresolvedTypeError

Inherits:
RuntimeTypeError
  • Object
show all
Defined in:
lib/graphql/unresolved_type_error.rb

Overview

Error raised when the value provided for a field can't be resolved to one of the possible types for the field.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, field, parent_type, resolved_type, possible_types) ⇒ UnresolvedTypeError

Returns a new instance of UnresolvedTypeError.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/graphql/unresolved_type_error.rb', line 33

def initialize(value, field, parent_type, resolved_type, possible_types)
  @value = value
  @field = field
  @parent_type = parent_type
  @resolved_type = resolved_type
  @possible_types = possible_types
  message = "The value from \"#{field.graphql_name}\" on \"#{parent_type.graphql_name}\" could not be resolved to \"#{field.type.to_type_signature}\". " \
    "(Received: `#{resolved_type.inspect}`, Expected: [#{possible_types.map(&:graphql_name).join(", ")}]) " \
    "Make sure you have defined a `resolve_type` proc on your schema and that value `#{value.inspect}` " \
    "gets resolved to a valid type. You may need to add your type to `orphan_types` if it implements an " \
    "interface but isn't a return type of any other field."
  super(message)
end

Instance Attribute Details

#field ⇒ Object (readonly)

Returns

  • GraphQL::Field — The field whose value couldn't be resolved (field.type is type which couldn't be resolved)


16
17
18
# File 'lib/graphql/unresolved_type_error.rb', line 16

def field
  @field
end

#parent_type ⇒ Object (readonly)

Returns

  • GraphQL::BaseType — The owner of field


21
22
23
# File 'lib/graphql/unresolved_type_error.rb', line 21

def parent_type
  @parent_type
end

#possible_types ⇒ Object (readonly)

Returns

  • Array<GraphQL::BaseType> — The allowed options for resolving value to field.type


31
32
33
# File 'lib/graphql/unresolved_type_error.rb', line 31

def possible_types
  @possible_types
end

#resolved_type ⇒ Object (readonly)

Returns



26
27
28
# File 'lib/graphql/unresolved_type_error.rb', line 26

def resolved_type
  @resolved_type
end

#value ⇒ Object (readonly)

Returns

  • Object — The runtime value which couldn't be successfully resolved with resolve_type


11
12
13
# File 'lib/graphql/unresolved_type_error.rb', line 11

def value
  @value
end