-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context link is not capturing reactive var changes #7338
Comments
benjamn
added a commit
that referenced
this issue
Nov 20, 2020
In the context of a larger cache read operation, accessing a reactive variable automatically associates the variable with the cache, so future updates to the variable can be broadcast to the cache. Outside this context, it may not be possible for the variable to discover the currently active cache. For example, there is no currently active cache in asynchronous ApolloLink code (#7338). Since we recently added a `reactiveVar.forgetCache(cache)` in #7279, I think it makes sense to have a manual way to do the opposite, which I have decided to call `reactiveVar.attachCache(cache)`. Although this attachment is manual at the moment, in a hypothetical future where the client/cache manage the persistence of reactive variables, it should be easy to attach the appropriate cache to those variables when they are first initialized, which would enable reactive updates from literally anywhere, with no additional effort by the developer.
benjamn
added a commit
that referenced
this issue
Nov 20, 2020
In the context of a larger cache read operation, accessing a reactive variable automatically associates the variable with the cache, so future updates to the variable can be broadcast to the cache. Outside this context, it may not be possible for the variable to discover the currently active cache. For example, there is no currently active cache in asynchronous ApolloLink code (#7338). Since we recently added a `reactiveVar.forgetCache(cache)` in #7279, I think it makes sense to have a manual way to do the opposite, which I have decided to call `reactiveVar.attachCache(cache)`. Although this attachment is manual at the moment, in a hypothetical future where the client/cache manage the persistence of reactive variables, it should be easy to attach the appropriate cache to those variables when they are first initialized, which would enable reactive updates from literally anywhere, with no additional effort by the developer.
Addressed by #7350 - thanks! |
I suspect this issue may not have been fixed, as suggested in #7350 (comment) I have created a reproduction repo at https://github.com/codazzo/apollo-client-reactive-context-repro |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I created a language link:
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.
The text was updated successfully, but these errors were encountered: