Method: GraphQL::Dataloader::Source#sync
- Defined in:
- lib/graphql/dataloader/source.rb
#sync(pending_result_keys) ⇒ void
This method returns an undefined value.
Wait for a batch, if there's anything to batch. Then run the batch and update the cache.
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/graphql/dataloader/source.rb', line 107 def sync(pending_result_keys) @dataloader.yield(self) iterations = 0 while pending_result_keys.any? { |key| !@results.key?(key) } iterations += 1 if iterations > MAX_ITERATIONS raise "#{self.class}#sync tried #{MAX_ITERATIONS} times to load pending keys (#{pending_result_keys}), but they still weren't loaded. There is likely a circular dependency#{@dataloader.fiber_limit ? " or `fiber_limit: #{@dataloader.fiber_limit}` is set too low" : ""}." end @dataloader.yield(self) end nil end |