Class: GraphQL::Dataloader::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/dataloader/request.rb

Overview

See Source#request which returns an instance of this

Direct Known Subclasses

RequestAll

Instance Method Summary collapse

Constructor Details

#initialize(source, key) ⇒ Request

Returns a new instance of Request.



8
9
10
11
# File 'lib/graphql/dataloader/request.rb', line 8

def initialize(source, key)
  @source = source
  @key = key
end

Instance Method Details

#load ⇒ Object

Call this method to cause the current Fiber to wait for the results of this request.

Returns

  • Object — the object loaded for key

:call-seq:

load() -> Object


21
22
23
# File 'lib/graphql/dataloader/request.rb', line 21

def load
  @source.load(@key)
end

#load_with_deprecation_warning ⇒ Object



25
26
27
28
# File 'lib/graphql/dataloader/request.rb', line 25

def load_with_deprecation_warning
  warn("Returning `.request(...)` from GraphQL::Dataloader is deprecated, use `.load(...)` instead. (See usage of #{@source} with #{@key.inspect}).")
  load
end