I want to add a Context Link to an existing client's Apollo Link chain.
Here are two GitHub issues I've read through: First, Second.
I do not want to use local storage to store the token as the docs show here.
I have an auth provider which stores my token. After storing my token I'd like to add a Context Link to the Apollo Client's links
const authLink = setContext((_, { headers }) => {
const newHeaders = { ...headers };
if (token) newHeaders.authorization = `Bearer ${token}`;
return {
headers: newHeaders,
};
});
I know I can access the client via useClient
. How do I append this link to the client's already existing from my component without doing it before making the client?
link: authLink.concat(httpLink)
or link: authLink.concat(whateverLinksApolloHas)