Method: GraphQL::Dataloader::Source#run_pending_keys

Defined in:
lib/graphql/dataloader/source.rb

#run_pending_keysvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Called by GraphQL::Dataloader to resolve and pending requests to this source.



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/graphql/dataloader/source.rb', line 140

def run_pending_keys
  if !@fetching.empty?
    @fetching.each_key { |k| @pending.delete(k) }
  end
  return if @pending.empty?
  fetch_h = @pending
  @pending = {}
  @fetching.merge!(fetch_h)
  results = fetch(fetch_h.values)
  fetch_h.each_with_index do |(key, _value), idx|
    @results[key] = results[idx]
  end
  nil
rescue StandardError => error
  fetch_h.each_key { |key| @results[key] = error }
ensure
  fetch_h && fetch_h.each_key { |k| @fetching.delete(k) }
end