docs/source/api/link/apollo-link-batch-http.mdx
<DocBlock canonicalReference="@apollo/client/link/batch-http!BatchHttpLink:class" customOrder={["summary", "example", "remarks"]} />
constructor(
options: BatchHttpLink.Options & ClientAwarenessLink.Options = {}
): BatchHttpLink
The batch HTTP link currently uses the context in two different ways, per batch and per query. The context fields below are used per batch and taken from the first operation in the batch.
| Option | Description |
|---|---|
headers | An object representing values to be sent as headers on the request |
credentials | A string representing the credentials policy you want for the fetch call |
uri | A string of the endpoint you want to fetch from |
fetchOptions | Any overrides of the fetch options argument to pass to the fetch call |
For each query, the http field is used to modify each individual query in the batch, such as persisted queries (see below).
After your GraphQL endpoint successfully responds with the result of an operation, BatchHttpLink sets the Response object as the response field of the operation context. This enables each previous link in your link chain to interact with the response.
See Customizing fetch.
<InterfaceDetails canonicalReference="@apollo/client/link/batch-http!BatchHttpLink.Options:interface" headingLevel={3} displayName="BatchHttpLink.Options" customPropertyOrder={["uri", "headers", "credentials", "fetchOptions"]} />
<InterfaceDetails canonicalReference="@apollo/client/link/batch-http!BatchHttpLink.ContextOptions:interface" headingLevel={3} displayName="BatchHttpLink.ContextOptions" />