Class: GraphQL::Query::SerialExecution::FieldResolution::FieldResolveStep

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query/serial_execution/field_resolution.rb

Overview

A `.call`-able suitable to be the last step in a middleware chain

Instance Method Summary collapse

Constructor Details

#initialize(irep_node) ⇒ FieldResolveStep

Returns a new instance of FieldResolveStep.


83
84
85
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 83

def initialize(irep_node)
  @irep_node = irep_node
end

Instance Method Details

#call(_parent_type, parent_object, field_definition, field_args, context, _next = nil) ⇒ Object

Execute the field's resolve method


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 88

def call(_parent_type, parent_object, field_definition, field_args, context, _next = nil)
  # setup
  context.ast_node = @irep_node.ast_node
  context.irep_node = @irep_node

  # resolve
  value = field_definition.resolve(parent_object, field_args, context)

  # teardown
  context.ast_node = nil
  context.irep_node = nil

  # return
  value
end