Class: GraphQL::Query::Context::FieldResolutionContext

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/graphql/query/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:, path:, irep_node:) ⇒ FieldResolutionContext

Returns a new instance of FieldResolutionContext.



69
70
71
72
73
# File 'lib/graphql/query/context.rb', line 69

def initialize(context:, path:, irep_node:)
  @context = context
  @path = path
  @irep_node = irep_node
end

Instance Attribute Details

#irep_nodeObject (readonly)

Returns the value of attribute irep_node.



67
68
69
# File 'lib/graphql/query/context.rb', line 67

def irep_node
  @irep_node
end

#pathObject (readonly)

Returns the value of attribute path.



67
68
69
# File 'lib/graphql/query/context.rb', line 67

def path
  @path
end

Instance Method Details

#add_error(error) ⇒ void

This method returns an undefined value.

Add error to current field resolution.

Parameters:



85
86
87
88
89
90
91
92
93
94
# File 'lib/graphql/query/context.rb', line 85

def add_error(error)
  unless error.is_a?(ExecutionError)
    raise TypeError, "expected error to be a ExecutionError, but was #{error.class}"
  end

  error.ast_node ||= irep_node.ast_node
  error.path ||= path
  errors << error
  nil
end

#ast_nodeGraphQL::Language::Nodes::Field

Returns The AST node for the currently-executing field.

Returns:



78
79
80
# File 'lib/graphql/query/context.rb', line 78

def ast_node
  @irep_node.ast_node
end