A terminating link for Apollo Client that batches multiple GraphQL operations (queries, mutations) into a single HTTP POST request to reduce network overhead. Current version is 1.2.14, last updated in 2019, and part of the Apollo Link ecosystem. It is in maintenance mode; the successor is the `@apollo/client` core link. Key differentiator: unlike serial requests, it groups operations by configurable batch key, interval (default 10ms), and max count (default 10). Requires `graphql` peer dependency and a `fetch` polyfill for non-browser environments (e.g., `unfetch` or `node-fetch`). Ships TypeScript types. Use only with Apollo Client v2; v3 uses `@apollo/client/link/batch-http`.
npm install apollo-link-batch-httpVerified import paths — ran on the pinned version, not inferred.
Creates an Apollo Client with batch HTTP link, configuring max batch size and interval, then executes a query.
Migrate to `import { BatchHttpLink } from '@apollo/client/link/batch-http'` when upgrading to Apollo Client v3.Provide a custom `batchKey` function that returns a unique key per operation (e.g., based on operation name or context).
Avoid setting `fetchOptions.method` to 'GET'. Use `apollo-link-http` for GET requests.
Install and pass a fetch polyfill such as `node-fetch` or `unfetch` via `new BatchHttpLink({ fetch: require('node-fetch') })`.Downgrade `graphql` to a supported version or migrate to `@apollo/client` which supports newer graphql.
Install a polyfill like `node-fetch` and pass it: `new BatchHttpLink({ fetch: require('node-fetch') })`.Use `import { BatchHttpLink } from 'apollo-link-batch-http'` instead of `import BatchHttpLink from...`.Ensure server supports batch GraphQL (array of queries). Consider setting `batchMax: 1` to send individual requests.