-
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
reactive variables not working after calling resetStore() #7664
Comments
got same issue today |
@jcreighton @benjamn could you please look at this issue? Looks like you were recently fixing issues related to reactive variables and this issue is also related to reactive variables. Looks like if any active query contains reactive variables this query will not be updated when reactive variables values are changed. This happens after calling And this issue happens after calling Thanks a lot. |
@pavelspichonak It looks like your reproduction (thank you!) uses 3.3.7. I know you reported this happening with 3.3.8 but when I upgrade to that version in the reproduction, the reactive variable does update. Could you take a second look at that reproduction with 3.3.8? @LittleCryingGirl I see you've also reported the issue with 3.3.8. If you're able to create a runnable reproduction, please do. |
@jcreighton yeah you are right. In the sandbox after updating to 3.3.8 it works. But in my project I use 3.3.8 and still have this issue. I will try to figure out why behavior in my project differs from behavior in the sandbox and will write again. Thanks. |
@benjamn @jcreighton guys after spending 3-4 hours finally I found the case when this issue happens. Here is a sandbox Now apollo version is 3.3.8 If you click "click to logout" button - all works good and you will see |
Now I use two queries and each query uses its own reactive variable. Also I use one query in the root component(App component) and the second query is used in nested component(Header component) |
Hi @jcreighton @benjamn. Are there any updates related to this issue? Thank you. |
@vladimir-drachuk We have a company-wide deadline today (peer reviews are due), but @jcreighton is actively working on fixing this. |
@benjamn @jcreighton thanks a lot for fixing this issue! Now it works. But may I ask you a question here? It is related to When user is logging out, I set reactive variable value to And there is query which uses this variable:
Some UI parts are rendered or not based on this query. After setting So I use setTimeout like this:
It works. Now when |
@pavelspichonak Thanks for following up. I wonder if the cache notification resulting from Can you try forcing the broadcast like so? isLoggedIn(false);
client["queryManager"].broadcastQueries();
client.resetStore(); TypeScript might complain about accessing the private |
@benjamn hey, I have the same issue but with clearStore, it also stops UI from being rerendered. And your code |
Intended outcome:
I have a reactive variable:
export const isLoggedIn = makeVar(false);
Here is client initialization:
And I have a query:
I use this query in some place like this:
const { data: { user: { isLoggedIn } } } = useQuery(GET_IS_USER_LOGGED_IN);
Then I call
graphqlClient.resetStore();
and after that I try to update reactive variable value like this
isLoggedIn(true);
isLoggedIn
should becometrue
in this code:const { data: { user: { isLoggedIn } } } = useQuery(GET_IS_USER_LOGGED_IN);
Actual outcome:
When you call
graphqlClient.resetStore();
and after that you update reactive variable value like this:
isLoggedIn(true);
queries which use this reactive variable are not updated, for example this query still returns
false
inisLoggedIn
property:const { data: { user: { isLoggedIn } } } = useQuery(GET_IS_USER_LOGGED_IN);
But if I never use
graphqlClient.resetStore();
and try to update reactive variable value like thisisLoggedIn(true);
all works great.How to reproduce the issue:
Here is sandbox
First click click to reset store button and after that click click to change reactive variable value button. You will see that value is still false.
But if you just click click to change reactive variable value button, value will be changed to
true
.Versions
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 15.4.0 - ~/.nvm/versions/node/v15.4.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.0.15 - ~/.nvm/versions/node/v15.4.0/bin/npm
Browsers:
Chrome: 88.0.4324.150
Edge: 88.0.705.63
Firefox: 84.0.1
Safari: 13.0.5
npmPackages:
@apollo/client: ^3.3.8 => 3.3.8
The text was updated successfully, but these errors were encountered: