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.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method 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.graphql_name}.#{@field.graphql_name}")
end

Class Attribute Details

.parent_classObject

Returns the value of attribute parent_class.



33
34
35
# File 'lib/graphql/invalid_null_error.rb', line 33

def parent_class
  @parent_class
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

Class Method Details

.inspectObject



41
42
43
44
45
46
47
# File 'lib/graphql/invalid_null_error.rb', line 41

def inspect
  if (name.nil? || parent_class.name.nil?) && parent_class.respond_to?(:mutation) && (mutation = parent_class.mutation)
    "#{mutation.inspect}::#{parent_class.graphql_name}::InvalidNullError"
  else
    super
  end
end

.subclass_for(parent_class) ⇒ Object



35
36
37
38
39
# File 'lib/graphql/invalid_null_error.rb', line 35

def subclass_for(parent_class)
  subclass = Class.new(self)
  subclass.parent_class = parent_class
  subclass
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