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
Query does not trigger a rerender after a clearStore #8995
Comments
@MartijnHols My first instinct is to steer you towards For example, maybe you're using If that's the case, then I think there might be a missing middle ground between |
First of all, I went with Indeed I don't want to restart the queries. When I do, the I have a hook const isLoggedIn = useIsLoggedIn()
return (
<Providers>
<Router />
{/* Set the `user` context in Sentry */}
{isLoggedIn && <SentryUser />}
{/* Activate subscriptions (which also rely on data from queries) */}
{isLoggedIn && <Notifications />}
{isLoggedIn && <UserUpdated />}
</Providers>
) Most of the queries within the |
I'm also having troubles resetting/clearing the store after logout. Refetching queries, which happens when you use @MartijnHols I've added my opinion to the discussion which lead to PR #8873. You may want to follow the discussion. |
I'm facing a similar issue after upgrading from 3.3.21 to 3.4.16. Previously this imperative query would fetch and store data and re-render my useQuery hook with 'cache-only'. Now the hook doesn't trigger a re-render anymore. It sill has the correct data if something else triggers a new render. const result = await client.query<
GetAuthUserQuery,
GetAuthUserQueryVariables
>({
errorPolicy: 'ignore',
query: GetAuthUserDocument,
variables: {userId},
}); |
When checking the user's logged in state I do a
me { id }
query. This returnsnull
if the user is logged out. I then show the login page, and if a user logs in using the login mutations they get a "me" object with the data. During the login process, I clear the store and using an onClearStore, write the new "me" query data.This has stopped working in 3.4.16 after working in 3.4.15. I think this was caused by a change by @benjamn, specifically: https://github.com/apollographql/apollo-client/pull/8873/files#diff-b156746d5b1aac290dd27cf54cf4713d7ffbe0fce30e5a0dc6114d7b3529ea28R487
Intended outcome:
The query triggers a re-render, updating the component as it did in 3.4.13.
Actual outcome:
The query data is stale until something else triggers a re-render.
How to reproduce the issue:
Versions
I have tested the following versions:
ps. I feel like I reported this before, but I can't remember if I actually did and couldn't find another issue. I definitely didn't report it for the latest version though.
The text was updated successfully, but these errors were encountered: