Chaining apollo retryLink and errorLink

2.3k Views Asked by At
1

There are 1 best solutions below

0
On BEST ANSWER

It depends how you want your errorLink logic to work, from the docs

Additive composition involves combining a set of links into a serially executed chain

and the Error Link

is called after the GraphQL operation completes and execution is moving back up your link chain

so if you place the retryLink before the errorLink

ApolloLink.from([retryLink, errorLink])

the errorLink will also be executed with the retries once the respective result is traveling back up the chain, in other words (if you are using the default docs example), there should be a console log on every attempt and attempts.max console logs in total.

In case the order is flipped the errorLink will be called after the retryLink is complete and the result traveled all the way back up, so there should be 1 console log from the errorLink call.