Class: GraphQL::Execution::Next::LoadArgumentStep

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/execution/next/load_argument_step.rb

Instance Method Summary collapse

Constructor Details

#initialize(field_resolve_step:, arguments:, load_receiver:, argument_value:, argument_definition:, argument_key:) ⇒ LoadArgumentStep

Returns a new instance of LoadArgumentStep.



6
7
8
9
10
11
12
13
14
# File 'lib/graphql/execution/next/load_argument_step.rb', line 6

def initialize(field_resolve_step:, arguments:, load_receiver:, argument_value:, argument_definition:, argument_key:)
  @field_resolve_step = field_resolve_step
  @load_receiver = load_receiver
  @arguments = arguments
  @argument_value = argument_value
  @argument_definition = argument_definition
  @argument_key = argument_key
  @loaded_value = nil
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/graphql/execution/next/load_argument_step.rb', line 21

def call
  context = @field_resolve_step.selections_step.query.context
  @loaded_value = @load_receiver.load_and_authorize_application_object(@argument_definition, @argument_value, context)
  if (runner = @field_resolve_step.runner).resolves_lazies && runner.lazy?(@loaded_value)
    runner.dataloader.lazy_at_depth(@field_resolve_step.path.size, self)
  else
    assign_value
  end
rescue GraphQL::RuntimeError => err
  @loaded_value = err
  assign_value
rescue StandardError => stderr
  @loaded_value = begin
    context.query.handle_or_reraise(stderr)
  rescue GraphQL::ExecutionError => ex_err
    ex_err
  end
  assign_value
end

#valueObject



16
17
18
19
# File 'lib/graphql/execution/next/load_argument_step.rb', line 16

def value
  @loaded_value = @field_resolve_step.sync(@loaded_value)
  assign_value
end