Method: GraphQL::Execution::Interpreter::Runtime#evaluate_selection

Defined in:
lib/graphql/execution/interpreter/runtime.rb

#evaluate_selection(result_name, field_ast_nodes_or_ast_node, selections_result) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/graphql/execution/interpreter/runtime.rb', line 340

def evaluate_selection(result_name, field_ast_nodes_or_ast_node, selections_result) # rubocop:disable Metrics/ParameterLists
  return if selections_result.graphql_dead
  # As a performance optimization, the hash key will be a `Node` if
  # there's only one selection of the field. But if there are multiple
  # selections of the field, it will be an Array of nodes
  if field_ast_nodes_or_ast_node.is_a?(Array)
    field_ast_nodes = field_ast_nodes_or_ast_node
    ast_node = field_ast_nodes.first
  else
    field_ast_nodes = nil
    ast_node = field_ast_nodes_or_ast_node
  end
  field_name = ast_node.name
  owner_type = selections_result.graphql_result_type
  field_defn = query.types.field(owner_type, field_name)

  # Set this before calling `run_with_directives`, so that the directive can have the latest path
  runtime_state = get_current_runtime_state
  runtime_state.current_field = field_defn
  runtime_state.current_result = selections_result
  runtime_state.current_result_name = result_name

  owner_object = selections_result.graphql_application_value
  if field_defn.dynamic_introspection
    owner_object = field_defn.owner.wrap(owner_object, context)
  end

  if !field_defn.any_arguments?
    resolved_arguments = GraphQL::Execution::Interpreter::Arguments::EMPTY
    if field_defn.extras.size == 0
      evaluate_selection_with_resolved_keyword_args(
        NO_ARGS, resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_object, result_name, selections_result, runtime_state
      )
    else
      evaluate_selection_with_args(resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_object, result_name, selections_result, runtime_state)
    end
  else
    @query.arguments_cache.dataload_for(ast_node, field_defn, owner_object) do |resolved_arguments|
      runtime_state = get_current_runtime_state # This might be in a different fiber
      evaluate_selection_with_args(resolved_arguments, field_defn, ast_node, field_ast_nodes, owner_object, result_name, selections_result, runtime_state)
    end
  end
end