Exception: GraphQL::UnresolvedTypeError

Inherits:
Error
  • 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 Method Summary collapse

Constructor Details

#initialize(field_name, schema, field_type, parent_type, received_type) ⇒ UnresolvedTypeError

Returns a new instance of UnresolvedTypeError


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

def initialize(field_name, schema, field_type, parent_type, received_type)
  possible_types = field_type.kind.resolves? ? schema.possible_types(field_type) : [field_type]
  message = %|The value from "#{field_name}" on "#{parent_type}" could not be resolved to "#{field_type}". (Received: #{received_type.inspect}, Expected: [#{possible_types.map(&:inspect).join(", ")}])|
  super(message)
end