Sha256: 77fda3507b38a88edc7ab4474a1446fd681cefb6f7f9a15bc5499a39713a31ac

Contents?: true

Size: 916 Bytes

Versions: 46

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  # Raised automatically when a field's resolve function returns `nil`
  # for a non-null field.
  class InvalidNullError < GraphQL::RuntimeTypeError
    # @return [GraphQL::BaseType] The owner of {#field}
    attr_reader :parent_type

    # @return [GraphQL::Field] The field which failed to return a value
    attr_reader :field

    # @return [nil, GraphQL::ExecutionError] The invalid value for this field
    attr_reader :value

    def initialize(parent_type, field, value)
      @parent_type = parent_type
      @field = field
      @value = value
      super("Cannot return null for non-nullable field #{@parent_type.graphql_name}.#{@field.graphql_name}")
    end

    # @return [Hash] An entry for the response's "errors" key
    def to_h
      { "message" => message }
    end

    # @deprecated always false
    def parent_error?
      false
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
graphql-1.10.14 lib/graphql/invalid_null_error.rb
graphql-1.10.13 lib/graphql/invalid_null_error.rb
graphql-1.11.0 lib/graphql/invalid_null_error.rb
graphql-1.10.12 lib/graphql/invalid_null_error.rb
graphql-1.9.21 lib/graphql/invalid_null_error.rb
graphql-1.10.11 lib/graphql/invalid_null_error.rb
graphql-1.9.20 lib/graphql/invalid_null_error.rb
graphql-1.10.10 lib/graphql/invalid_null_error.rb
graphql-1.10.9 lib/graphql/invalid_null_error.rb
graphql-1.10.8 lib/graphql/invalid_null_error.rb
graphql-1.10.7 lib/graphql/invalid_null_error.rb
graphql-1.10.6 lib/graphql/invalid_null_error.rb
graphql-1.10.5 lib/graphql/invalid_null_error.rb
graphql-1.10.4 lib/graphql/invalid_null_error.rb
graphql-1.10.3 lib/graphql/invalid_null_error.rb
graphql-1.10.2 lib/graphql/invalid_null_error.rb
graphql-1.9.19 lib/graphql/invalid_null_error.rb
graphql-1.10.1 lib/graphql/invalid_null_error.rb
graphql-1.10.0 lib/graphql/invalid_null_error.rb
graphql-1.10.0.pre4 lib/graphql/invalid_null_error.rb