Method: GraphQL::Dataloader::Source#load

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

#load(value) ⇒ Object

Returns The result from #fetch for key. If key hasn't been loaded yet, the Fiber will yield until it's loaded.

Parameters:

  • value (Object)

    A loading value which will be passed to #fetch if it isn't already in the internal cache.

Returns:

  • (Object)

    The result from #fetch for key. If key hasn't been loaded yet, the Fiber will yield until it's loaded.



63
64
65
66
67
68
69
70
71
72
# File 'lib/graphql/dataloader/source.rb', line 63

def load(value)
  result_key = result_key_for(value)
  if @results.key?(result_key)
    result_for(result_key)
  else
    @pending[result_key] ||= normalize_fetch_key(value)
    sync([result_key])
    result_for(result_key)
  end
end