Skip to Content
Gqlts

Batching

Batching groups GraphQL operations that happen close together into one HTTP request. Use it when your GraphQL server accepts batched request payloads.

Apollo Server, Hasura, and many GraphQL gateways can support batching, but it must be enabled server-side.

Enable default batching

import { createClient } from './generated'; const client = createClient({ url: '/graphql', batch: true, });

Tune batching

const client = createClient({ url: '/graphql', batch: { batchInterval: 100, maxBatchSize: 10, }, });

Example

These three queries are sent in one network request when they happen inside the batch interval:

await Promise.all([ client.query({ user: { age: true, }, }), client.query({ user: { id: true, }, }), client.query({ user: { name: true, }, }), ]);

Keep the batch interval small for interactive screens. Larger intervals reduce network requests but can delay visible UI updates.