Exception: GraphQL::InvalidNullError

Inherits:
RuntimeTypeError 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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_type, field, value) ⇒ InvalidNullError

Returns a new instance of InvalidNullError.



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

def initialize(parent_type, field, value)
  @parent_type = parent_type
  @field = field
  @value = value
  super("Cannot return null for non-nullable field #{@parent_type.name}.#{@field.name}")
end

Instance Attribute Details

#fieldGraphQL::Field (readonly)

Returns The field which failed to return a value.

Returns:



10
11
12
# File 'lib/graphql/invalid_null_error.rb', line 10

def field
  @field
end

#parent_typeGraphQL::BaseType (readonly)

Returns The owner of #field.

Returns:



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

def parent_type
  @parent_type
end

#valuenil, GraphQL::ExecutionError (readonly)

Returns The invalid value for this field.

Returns:



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

def value
  @value
end

Instance Method Details

#parent_error?Boolean

Deprecated.

always false

Returns:

  • (Boolean)


28
29
30
# File 'lib/graphql/invalid_null_error.rb', line 28

def parent_error?
  false
end

#to_hHash

Returns An entry for the response's "errors" key.

Returns:

  • (Hash)

    An entry for the response's "errors" key



23
24
25
# File 'lib/graphql/invalid_null_error.rb', line 23

def to_h
  { "message" => message }
end