Sha256: 719c2efa8aee5493740f7bb264235e45bfdb84a52923af3db2205edcfef19ed3

Contents?: true

Size: 900 Bytes

Versions: 75

Compression:

Stored size: 900 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.name}.#{@field.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

75 entries across 75 versions & 1 rubygems

Version Path
graphql-1.7.4 lib/graphql/invalid_null_error.rb
graphql-1.7.3 lib/graphql/invalid_null_error.rb
graphql-1.7.2 lib/graphql/invalid_null_error.rb
graphql-1.7.1 lib/graphql/invalid_null_error.rb
graphql-1.7.0 lib/graphql/invalid_null_error.rb
graphql-1.6.8 lib/graphql/invalid_null_error.rb
graphql-1.6.7 lib/graphql/invalid_null_error.rb
graphql-1.6.6 lib/graphql/invalid_null_error.rb
graphql-1.6.5 lib/graphql/invalid_null_error.rb
graphql-1.6.4 lib/graphql/invalid_null_error.rb
graphql-1.5.15 lib/graphql/invalid_null_error.rb
graphql-1.6.3 lib/graphql/invalid_null_error.rb
graphql-1.6.2 lib/graphql/invalid_null_error.rb
graphql-1.6.1 lib/graphql/invalid_null_error.rb
graphql-1.6.0 lib/graphql/invalid_null_error.rb
graphql-1.5.14 lib/graphql/invalid_null_error.rb
graphql-1.5.13 lib/graphql/invalid_null_error.rb
graphql-1.5.7.1 lib/graphql/invalid_null_error.rb
graphql-1.5.12 lib/graphql/invalid_null_error.rb
graphql-1.5.11 lib/graphql/invalid_null_error.rb