apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.37k stars 2.66k forks source link

Context link is not capturing reactive var changes #7338

Closed sergio-bravo closed 3 years ago

sergio-bravo commented 3 years ago

I created a language link:

const languageLink = setContext((request, previousContext) => ({
  ...previousContext,
  headers: {
    ...previousContext.headers,
    "Accept-Language": getLanguage(),
  },
}));
export const getLanguage = (defaultLanguage?: string): string => {
  return languageVar() || defaultLanguage || "en";
};

It basically works and I can see the header is added to the request.

Problem: I expect cached queries to update automatically because the context has changed, but the new queries do not fire.

hwillson commented 3 years ago

Addressed by https://github.com/apollographql/apollo-client/pull/7350 - thanks!

codazzo commented 2 years ago

I suspect this issue may not have been fixed, as suggested in https://github.com/apollographql/apollo-client/pull/7350#issuecomment-731386808

I have created a reproduction repo at https://github.com/codazzo/apollo-client-reactive-context-repro What do you think @hwillson? I might be missing something.