Skip to main content

Batch resolvers

Batch resolvers group many field resolutions into a single call so servers avoid N+1 database or service requests while preserving GraphQL’s shape.

Practices implemented

Applies to

  • GraphQL servers
  • Execution engines and runtimes

Configuration (suggested defaults)

ParameterDefaultNotes
batchSchedulemicrotaskQueue batching within the same tick.
cacheScopeperRequestAvoid cross-request caching by default.

Implementation notes

  • Resolver signature should accept a list of parent objects.
  • Preserve positional ordering between inputs and outputs.
  • Return null or errors for missing items without reordering.
  • Prefer request-scoped caching for de-duplication within the same operation.

Cautions

  • Cross-request caches can leak data if not keyed by auth context.
  • Make batch failures granular; avoid failing the entire batch when possible.
  • Batching can increase end-to-end latency by expanding the critical path.

Problems addressed