Skip to content

Commit 7db9f23

Browse files
committed
Fix lazy resolving when no Dataloader
1 parent a2cbf25 commit 7db9f23

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/graphql/dataloader/null_dataloader.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ def run(trace_query_lazy: nil)
3737
end
3838

3939
def run_isolated
40-
new_dl = self.class.new
40+
# Reuse this instance because execution code may already have a reference to _this_ `dataloader` inside the given block.
41+
prev_lazies_at_depth = @lazies_at_depth
42+
@lazies_at_depth = @lazies_at_depth.dup.clear
4143
res = nil
42-
new_dl.append_job {
44+
append_job {
4345
res = yield
4446
}
45-
new_dl.run
47+
run
4648
res
49+
ensure
50+
@lazies_at_depth = prev_lazies_at_depth
4751
end
4852

4953
def clear_cache; end

0 commit comments

Comments
 (0)