Exception: GraphQL::UnresolvedTypeError

Inherits:
RuntimeTypeError 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



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/graphql/unresolved_type_error.rb', line 21

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.name}\" on \"#{parent_type}\" could not be resolved to \"#{field.type}\". " \
    "(Received: `#{resolved_type.inspect}`, Expected: [#{possible_types.map(&:inspect).join(", ")}]) " \
    "Make sure you have defined a `type_from_object` proc on your schema and that value `#{value.inspect}` " \
    "gets resolved to a valid type."
  super(message)
end

Instance Attribute Details

#fieldGraphQL::Field (readonly)

Returns The field whose value couldn't be resolved (field.type is type which couldn't be resolved)

Returns:

  • (GraphQL::Field)

    The field whose value couldn't be resolved (field.type is type which couldn't be resolved)



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

def field
  @field
end

#parent_typeGraphQL::BaseType (readonly)

Returns The owner of field

Returns:



13
14
15
# File 'lib/graphql/unresolved_type_error.rb', line 13

def parent_type
  @parent_type
end

#possible_typesArray<GraphQL::BaseType> (readonly)

Returns The allowed options for resolving value to field.type

Returns:

  • (Array<GraphQL::BaseType>)

    The allowed options for resolving value to field.type



19
20
21
# File 'lib/graphql/unresolved_type_error.rb', line 19

def possible_types
  @possible_types
end

#resolved_typeObject (readonly)

Returns The return of Schema#resolve_type for value

Returns:



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

def resolved_type
  @resolved_type
end

#valueObject (readonly)

Returns The runtime value which couldn't be successfully resolved with resolve_type

Returns:

  • (Object)

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



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

def value
  @value
end