Skip to content

Commit

Permalink
feat: add option to set terminating link (#402)
Browse files Browse the repository at this point in the history
* feat: add option to set terminating link

* cleanup
  • Loading branch information
mariusc23 authored May 7, 2024
1 parent a13fe65 commit 806f331
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/apollo/src/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface ConfigureClientOptions extends Omit<ApolloClientOptions<unknown
onNetworkError?: (err: ApolloError["networkError"], operation: Operation) => void;
onNotAuthorized?: (err: ApolloError["networkError"], operation: Operation) => void;
removeToken?: () => void;
terminatingLink?: ApolloLink;
}

const defaultFetch = typeof window !== "undefined" ? window.fetch : undefined;
Expand All @@ -70,6 +71,7 @@ export const configureClient = ({
onNetworkError,
onNotAuthorized,
removeToken,
terminatingLink,
uri,
...otherOptions
}: ConfigureClientOptions) => {
Expand Down Expand Up @@ -170,7 +172,9 @@ export const configureClient = ({

const links: ApolloLink[] = [errorLink, retryLink, authLink, ...extraLinks];

if (batch) {
if (terminatingLink) {
links.push(terminatingLink);
} else if (batch) {
links.push(
new BatchHttpLink({
batchInterval,
Expand Down

0 comments on commit 806f331

Please sign in to comment.