Sha256: 224e3c8b7b23deef2e33afd9d42c88f4f410b5f5c4769eb9701757d4c406f6e5

Contents?: true

Size: 687 Bytes

Versions: 13

Compression:

Stored size: 687 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(parent_type_name, field_name, value)
      @parent_type_name = parent_type_name
      @field_name = field_name
      @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

    # @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

13 entries across 13 versions & 1 rubygems

Version Path
graphql-1.2.6 lib/graphql/invalid_null_error.rb
graphql-1.2.5 lib/graphql/invalid_null_error.rb
graphql-1.2.4 lib/graphql/invalid_null_error.rb
graphql-1.2.3 lib/graphql/invalid_null_error.rb
graphql-1.2.2 lib/graphql/invalid_null_error.rb
graphql-1.2.1 lib/graphql/invalid_null_error.rb
graphql-1.2.0 lib/graphql/invalid_null_error.rb
graphql-1.1.0 lib/graphql/invalid_null_error.rb
graphql-1.0.0 lib/graphql/invalid_null_error.rb
graphql-0.19.4 lib/graphql/invalid_null_error.rb
graphql-0.19.3 lib/graphql/invalid_null_error.rb
graphql-0.19.2 lib/graphql/invalid_null_error.rb
graphql-0.19.1 lib/graphql/invalid_null_error.rb