Exception: GraphQL::InvalidNullError

Inherits:
Error
  • Object
show all
Defined in:
lib/graphql/invalid_null_error.rb

Overview

Raised automatically when a field’s resolve function returns ‘nil` for a non-null field.

Instance Method Summary collapse

Constructor Details

#initialize(field_name, value) ⇒ InvalidNullError

Returns a new instance of InvalidNullError.



5
6
7
8
# File 'lib/graphql/invalid_null_error.rb', line 5

def initialize(field_name, value)
  @field_name = field_name
  @value = value
end

Instance Method Details

#parent_error?Boolean

Returns Whether the null in question was caused by another error.

Returns:

  • (Boolean)

    Whether the null in question was caused by another error



18
19
20
# File 'lib/graphql/invalid_null_error.rb', line 18

def parent_error?
  @value.is_a?(GraphQL::ExecutionError)
end

#to_hHash

Returns An entry for the response’s “errors” key.

Returns:

  • (Hash)

    An entry for the response’s “errors” key



11
12
13
14
15
# File 'lib/graphql/invalid_null_error.rb', line 11

def to_h
  {
    "message" => "Cannot return null for non-nullable field #{@field_name}"
  }
end