Sha256: b321e865f7d647f2d8b93a653237eced15ba0fb30a808be408af3b33e450a552

Contents?: true

Size: 605 Bytes

Versions: 13

Compression:

Stored size: 605 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
      super("Cannot return null for non-nullable field #{@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-0.19.0 lib/graphql/invalid_null_error.rb
graphql-0.18.15 lib/graphql/invalid_null_error.rb
graphql-0.18.14 lib/graphql/invalid_null_error.rb
graphql-0.18.13 lib/graphql/invalid_null_error.rb
graphql-0.18.12 lib/graphql/invalid_null_error.rb
graphql-0.18.11 lib/graphql/invalid_null_error.rb
graphql-0.18.10 lib/graphql/invalid_null_error.rb
graphql-0.18.9 lib/graphql/invalid_null_error.rb
graphql-0.18.8 lib/graphql/invalid_null_error.rb
graphql-0.18.7 lib/graphql/invalid_null_error.rb
graphql-0.18.6 lib/graphql/invalid_null_error.rb
graphql-0.18.5 lib/graphql/invalid_null_error.rb
graphql-0.18.4 lib/graphql/invalid_null_error.rb