Sha256: 506a59063494ccc8c6ca39cb70354e6630d1f907a21a0c81a3799597027fd56d

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

Contents

module GraphQL
  # Raised automatically when a field's resolve function returns `nil`
  # for a non-null field.
  class InvalidNullError < RuntimeError
    def initialize(field_name, value)
      @field_name = field_name
      @value = value
    end

    # @return [Hash] An entry for the response's "errors" key
    def to_h
      {
        "message" => "Cannot return null for non-nullable field #{@field_name}"
      }
    end

    # @return [Boolean] Whether the null in question was caused by another error
    def parent_error?
      @value.is_a?(GraphQL::ExecutionError)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-0.11.1 lib/graphql/invalid_null_error.rb
graphql-0.11.0 lib/graphql/invalid_null_error.rb