Skip to content

Commit fa00910

Browse files
authored
Fix resolving loader when Loader.for is used without load (#31)
1 parent d7f17e0 commit fa00910

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/graphql/batch/loader.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def load_many(keys)
3333
end
3434

3535
def resolve #:nodoc:
36-
load_keys = @queue
36+
load_keys = queue
37+
return if load_keys.empty?
3738
@queue = nil
3839
perform(load_keys)
3940
check_for_broken_promises(load_keys)

test/loader_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@ def test_load_on_different_loaders
145145
def test_derived_cache_key
146146
assert_equal [:a, :b, :a], DerivedCacheKeyLoader.load_many([:a, :b, "a"]).sync
147147
end
148+
149+
def test_loader_for_without_load
150+
loader = EchoLoader.for
151+
GraphQL::Batch::Executor.current.wait_all
152+
end
148153
end

0 commit comments

Comments
 (0)