Method: GraphQL::Dataloader::Source#load_all

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

#load_all(values) ⇒ Object

Returns The result from #fetch for keys. If keys haven't been loaded yet, the Fiber will yield until they're loaded.

Parameters:

  • values (Array<Object>)

    Loading keys which will be passed to #fetch (or read from the internal cache).

Returns:

  • (Object)

    The result from #fetch for keys. If keys haven't been loaded yet, the Fiber will yield until they're loaded.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/graphql/dataloader/source.rb', line 76

def load_all(values)
  result_keys = []
  pending_keys = []
  values.each { |v|
    k = result_key_for(v)
    result_keys << k
    if !@results.key?(k)
      @pending[k] ||= normalize_fetch_key(v)
      pending_keys << k
    end
  }

  if !pending_keys.empty?
    sync(pending_keys)
  end

  result_keys.map { |k| result_for(k) }
end