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.



71
72
73
74
75
# File 'lib/graphql/query/context.rb', line 71

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.



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

def irep_node
  @irep_node
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#add_error(error) ⇒ void

This method returns an undefined value.

Add error to current field resolution.

Parameters:



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

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:



80
81
82
# File 'lib/graphql/query/context.rb', line 80

def ast_node
  @irep_node.ast_node
end