From 25772285e70dfe9eb279265e3a212c3223e4a877 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Thu, 25 Apr 2024 19:00:41 -0700 Subject: [PATCH 1/2] stash --- lib/graphql/execution/interpreter/runtime.rb | 11 ++++++++++- .../active_record_relation_connection_spec.rb | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/graphql/execution/interpreter/runtime.rb b/lib/graphql/execution/interpreter/runtime.rb index 560d800847..8e4da440b4 100644 --- a/lib/graphql/execution/interpreter/runtime.rb +++ b/lib/graphql/execution/interpreter/runtime.rb @@ -208,7 +208,16 @@ def gather_selections(owner_object, owner_type, selections, selections_to_run = def evaluate_selections(owner_object, owner_type, is_eager_selection, gathered_selections, selections_result, target_result, parent_object, runtime_state) # rubocop:disable Metrics/ParameterLists finished_jobs = 0 enqueued_jobs = gathered_selections.size - gathered_selections.each do |result_name, field_ast_nodes_or_ast_node| + + x = gathered_selections.dup + x.delete("nodes") + z = x.to_a + + if gathered_selections.include?("nodes") + z.insert(0, ["nodes", gathered_selections["nodes"]]) + end + + z.each do |result_name, field_ast_nodes_or_ast_node| @dataloader.append_job { runtime_state = get_current_runtime_state evaluate_selection( diff --git a/spec/graphql/pagination/active_record_relation_connection_spec.rb b/spec/graphql/pagination/active_record_relation_connection_spec.rb index b527701450..7004e6b4e9 100644 --- a/spec/graphql/pagination/active_record_relation_connection_spec.rb +++ b/spec/graphql/pagination/active_record_relation_connection_spec.rb @@ -181,6 +181,7 @@ def total_count end it "runs two queries for `nodes` and `hasNextPage` if hasNextPage is selected first" do + results = nil log = with_active_record_log do results = schema.execute("{ items(first: 3) { @@ -194,8 +195,8 @@ def total_count }") end assert_equal ["Item", "Item", "Item"], results["data"]["items"]["nodes"].map { |i| i["__typename"] } - assert_equal 2, log.split("\n").size, "It runs two queries" - assert_equal 1, log.scan("COUNT(").size, "It runs one count query" + assert_equal 1, log.split("\n").size, "It runs one query" + assert_equal 0, log.scan("COUNT(").size, "It runs no count query" end describe "already-loaded ActiveRecord relations" do From 5ee02578b343fd9eeab37f4632ce9d0726af3778 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Thu, 25 Apr 2024 19:10:36 -0700 Subject: [PATCH 2/2] reorganize --- spec/graphql/authorization_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/graphql/authorization_spec.rb b/spec/graphql/authorization_spec.rb index fee0731e14..1def0a7c0c 100644 --- a/spec/graphql/authorization_spec.rb +++ b/spec/graphql/authorization_spec.rb @@ -715,8 +715,8 @@ def auth_execute(*args, **kwargs) assert_equal "RelayObjectEdge", edge["__typename"] unauthorized_object_paths = [ - ["unauthorizedConnection", "edges", 0, "node"], ["unauthorizedConnection", "nodes", 0], + ["unauthorizedConnection", "edges", 0, "node"], ["unauthorizedEdge", "node"] ]