Class: GraphQL::Dataloader::Request

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

Overview

Direct Known Subclasses

RequestAll

Instance Method Summary collapse

Constructor Details

#initialize(source, key) ⇒ Request

Returns a new instance of Request.



6
7
8
9
# File 'lib/graphql/dataloader/request.rb', line 6

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

Instance Method Details

#loadObject

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

Returns:

  • (Object)

    the object loaded for key



14
15
16
# File 'lib/graphql/dataloader/request.rb', line 14

def load
  @source.load(@key)
end

#load_with_deprecation_warningObject



18
19
20
21
# File 'lib/graphql/dataloader/request.rb', line 18

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