Method: GraphQL::Dataloader.with_dataloading

Defined in:
lib/graphql/dataloader.rb

.with_dataloading(&block) ⇒ Object

Call the block with a Dataloader instance, then run all enqueued jobs and return the result of the block.



50
51
52
53
54
55
56
57
58
# File 'lib/graphql/dataloader.rb', line 50

def self.with_dataloading(&block)
  dataloader = self.new
  result = nil
  dataloader.append_job {
    result = block.call(dataloader)
  }
  dataloader.run
  result
end