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(parent_type_name, field_name, value) ⇒ InvalidNullError

Returns a new instance of InvalidNullError.



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

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

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



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

def to_h
  { "message" => message }
end