Sha256: c181e4e16ccdb135146f4e6a810b3af06d5850a2d3712c4b1d91d7da583835ce

Contents?: true

Size: 598 Bytes

Versions: 19

Compression:

Stored size: 598 Bytes

Contents

module GraphQL
  # Raised automatically when a field's resolve function returns `nil`
  # for a non-null field.
  class InvalidNullError < GraphQL::Error
    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

19 entries across 19 versions & 1 rubygems

Version Path
graphql-0.18.3 lib/graphql/invalid_null_error.rb
graphql-0.18.2 lib/graphql/invalid_null_error.rb
graphql-0.18.1 lib/graphql/invalid_null_error.rb
graphql-0.18.0 lib/graphql/invalid_null_error.rb
graphql-0.17.2 lib/graphql/invalid_null_error.rb
graphql-0.17.1 lib/graphql/invalid_null_error.rb
graphql-0.17.0 lib/graphql/invalid_null_error.rb
graphql-0.16.1 lib/graphql/invalid_null_error.rb
graphql-0.16.0 lib/graphql/invalid_null_error.rb
graphql-0.15.3 lib/graphql/invalid_null_error.rb
graphql-0.15.2 lib/graphql/invalid_null_error.rb
graphql-0.14.2 lib/graphql/invalid_null_error.rb
graphql-0.15.1 lib/graphql/invalid_null_error.rb
graphql-0.15.0 lib/graphql/invalid_null_error.rb
graphql-0.14.1 lib/graphql/invalid_null_error.rb
graphql-0.14.0 lib/graphql/invalid_null_error.rb
graphql-0.13.0 lib/graphql/invalid_null_error.rb
graphql-0.12.1 lib/graphql/invalid_null_error.rb
graphql-0.12.0 lib/graphql/invalid_null_error.rb