Non-Blocking Data Loading for GraphQL

You can pass nonblocking: true to enable a non-blocking dataloader implementation based on Ruby 3’s Fiber.scheduler API:

class MySchema < GraphQL::Schema
  use GraphQL::Dataloader, nonblocking: true # enable parallel data loading

Alternatively, you can add a non-blocking GraphQL::Dataloader instance to context[:dataloader]:

context = {
  # ...
  dataloader: true),
MySchema.execute(query_string, context: context, ...)

Additionally, you must set up a Fiber scheduler with Fiber.set_scheduler before running your query:


The scheduler must implement Fiber::SchedulerImplementation. Existing implementations can be found at Fiber Scheduler List.