Skip to main content
DataLoader coalesces many individual load(key) calls made within one event-loop tick into a single batch function call, and caches each key for the life of the loader. Create one loader per request (usually on your Context) so its cache and batching stay request-scoped.
The batch function receives the list of distinct keys and must return a list of the same length, in the same order. Per-key exceptions are mapped back to the matching load() future, so one failed key does not fail the rest.
  • max_batch_size chunks large batches into several calls.
  • cache=False disables per-key caching; cache_key_fn customizes the cache key.
  • load_many, prime, clear, and clear_all manage the queue and cache.