Skip to content

Commit

Permalink
Pass return_type instead of re-accessing it
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Jan 30, 2023
1 parent 7e6eac9 commit 7e18089
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion benchmark/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def self.profile_large_introspection
100.times do |n|
obj_t = Class.new(GraphQL::Schema::Object) do
graphql_name("Object#{n}")
5.times do |n2|
20.times do |n2|
field :"field#{n2}", String do
argument :arg, String
end
Expand Down
10 changes: 4 additions & 6 deletions lib/graphql/execution/interpreter/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def evaluate_selection(path, result_name, field_ast_nodes_or_ast_node, scoped_co
raise "Invariant: no field for #{owner_type}.#{field_name}"
end
end
# HERE

return_type = field_defn.type

next_path = path.dup
Expand All @@ -426,19 +426,17 @@ def evaluate_selection(path, result_name, field_ast_nodes_or_ast_node, scoped_co
total_args_count = field_defn.arguments(context).size
if total_args_count == 0
resolved_arguments = GraphQL::Execution::Interpreter::Arguments::EMPTY
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object)
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object, return_type)
else
# TODO remove all arguments(...) usages?
@query.arguments_cache.dataload_for(ast_node, field_defn, object) do |resolved_arguments|
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object)
evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object, return_type)
end
end
end

def evaluate_selection_with_args(arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selection_result, parent_object) # rubocop:disable Metrics/ParameterLists
def evaluate_selection_with_args(arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selection_result, parent_object, return_type) # rubocop:disable Metrics/ParameterLists
context.scoped_context = scoped_context
# HERE
return_type = field_defn.type
after_lazy(arguments, owner: owner_type, field: field_defn, path: next_path, ast_node: ast_node, scoped_context: context.scoped_context, owner_object: object, arguments: arguments, result_name: result_name, result: selection_result) do |resolved_arguments|
if resolved_arguments.is_a?(GraphQL::ExecutionError) || resolved_arguments.is_a?(GraphQL::UnauthorizedError)
continue_value(next_path, resolved_arguments, owner_type, field_defn, return_type.non_null?, ast_node, result_name, selection_result)
Expand Down

0 comments on commit 7e18089

Please sign in to comment.