Skip to content

Comments

Fix @defer on lazy objects when Dataloader isn't used#5550

Merged
rmosolgo merged 4 commits intomasterfrom
null-dataloader-isolated
Feb 23, 2026
Merged

Fix @defer on lazy objects when Dataloader isn't used#5550
rmosolgo merged 4 commits intomasterfrom
null-dataloader-isolated

Conversation

@rmosolgo
Copy link
Owner

Fixes #5490

.run_isolated(&block) may receive a block which already references a certain dataloader instance, and might call dataloader.lazy_at_depth(...) on it. In that case, the lazy is registered with the first NullDataloader instance, not the newly-created one. Then when .run is called on the newly-created instance, it doesn't find any of those registered lazies.

By reusing self instead of making a new instance, the references inside the given block are still "correct" -- the lazies given to dataloader.lazy_at_depth are properly found and resolved when self.run is called later on.

@rmosolgo rmosolgo added this to the 2.5.20 milestone Feb 23, 2026
@rmosolgo rmosolgo merged commit 9d84d8b into master Feb 23, 2026
13 checks passed
@rmosolgo rmosolgo deleted the null-dataloader-isolated branch February 23, 2026 15:16
@rmosolgo rmosolgo changed the title Null dataloader isolated Fix @defer on lazy objects when Dataloader isn't used Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GraphQL-Pro] Incompatibility between graphql-ruby and graphql-pro gems

1 participant