Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oliver/node evaluation sort #3

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/graphql/execution/interpreter/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion spec/graphql/authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down