GraphQL Query Batcher is a minimal (<700 bytes) JavaScript library that batches multiple GraphQL queries into a single HTTP request, reducing network overhead. Version 1.0.1 is current (unreleased yet, based on semver). It works by collecting queries within a configurable batch interval (default 6ms) and sending them together to a GraphQL endpoint that supports batching (e.g., Apollo Server). Key differentiators: extremely lightweight, zero dependencies, simple API with fetch and forceFetch methods. Unlike Apollo's batch link, this is standalone and framework-agnostic. Requires the server to accept an array of queries and return an array of results.
npm install graphql-query-batcherNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a batcher client with custom fetcher, sends batched queries, and shows both fetch and forceFetch methods.
Ensure GraphQL server supports batching, or set shouldBatch: false to send individual requests.
Prefer fetch() for normal usage; only use forceFetch when you need to bypass batching.
Set a larger batchInterval (e.g., 50ms) to allow more queries to accumulate.
Set maxBatchSize to a reasonable number like 10 to avoid overly large payloads.
Ensure the fetcher parameter is a function that takes a batched query and returns a promise of the parsed JSON response.
Disable batching (shouldBatch: false) or configure server to return array of results.
Use a fetch polyfill like 'node-fetch' or import from 'node-fetch' and pass as the fetcher argument.
No dependency data recorded yet.