class GraphQL::InvalidNullError
Raised automatically when a field’s resolve function returns nil for a non-null field.
Attributes
Returns
-
GraphQL::Field— The field which failed to return a value
Returns
-
Boolean— indicates an array result caused the error
Returns
-
GraphQL::BaseType— The owner of field
Public Class Methods
Source
# File lib/graphql/invalid_null_error.rb, line 63 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
Calls superclass method
Source
# File lib/graphql/invalid_null_error.rb, line 36 def initialize(parent_type, field, ast_node_or_nodes, is_from_array: false, path: nil, element_type: nil) @parent_type = parent_type @field = field @ast_nodes = Array(ast_node_or_nodes) @is_from_array = is_from_array @path = path # For List elements, identify the non-null error is for an # element and the required element type so it's not ambiguous # whether it was caused by a null instead of the list or a # null element. if @is_from_array element_type ||= @field.type.of_type.of_type super("Cannot return null for non-nullable element of type '#{element_type.to_type_signature}' for #{@parent_type.graphql_name}.#{@field.graphql_name}") else super("Cannot return null for non-nullable field #{@parent_type.graphql_name}.#{@field.graphql_name}") end end
Calls superclass method
Source
# File lib/graphql/invalid_null_error.rb, line 57 def subclass_for(parent_class) subclass = Class.new(self) subclass.parent_class = parent_class subclass end
Public Instance Methods
# File lib/graphql/invalid_null_error.rb, line 23 def ast_node @ast_nodes.first end
Returns
-
GraphQL::Language::Nodes::Field— the field where the error occurred