Sha256: 641e215e46cb50b6eee206f84c48181dbcdb9106ec2bc093be851b7691e1128c

Contents?: true

Size: 1.43 KB

Versions: 24

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true
module GraphQL
  # Error raised when the value provided for a field
  # can't be resolved to one of the possible types for the field.
  class UnresolvedTypeError < GraphQL::RuntimeTypeError
    # @return [Object] The runtime value which couldn't be successfully resolved with `resolve_type`
    attr_reader :value

    # @return [GraphQL::Field] The field whose value couldn't be resolved (`field.type` is type which couldn't be resolved)
    attr_reader :field

    # @return [GraphQL::BaseType] The owner of `field`
    attr_reader :parent_type

    # @return [Object] The return of {Schema#resolve_type} for `value`
    attr_reader :resolved_type

    # @return [Array<GraphQL::BaseType>] The allowed options for resolving `value` to `field.type`
    attr_reader :possible_types

    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
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
graphql-1.8.0.pre9 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre8 lib/graphql/unresolved_type_error.rb
graphql-1.7.13 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre7 lib/graphql/unresolved_type_error.rb
graphql-1.7.12 lib/graphql/unresolved_type_error.rb
graphql-1.7.11 lib/graphql/unresolved_type_error.rb
graphql-1.7.10 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre6 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre5 lib/graphql/unresolved_type_error.rb
graphql-1.7.9 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre4 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre3 lib/graphql/unresolved_type_error.rb
graphql-1.7.8 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre2 lib/graphql/unresolved_type_error.rb
graphql-1.7.7 lib/graphql/unresolved_type_error.rb
graphql-1.8.0.pre1 lib/graphql/unresolved_type_error.rb
graphql-1.7.6 lib/graphql/unresolved_type_error.rb
graphql-1.7.5 lib/graphql/unresolved_type_error.rb
graphql-1.7.4 lib/graphql/unresolved_type_error.rb
graphql-1.7.3 lib/graphql/unresolved_type_error.rb