Skip to content
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

Clearing the client state using 'resetStore' #1509

Closed
oavasilcai opened this issue Mar 28, 2017 · 6 comments
Closed

Clearing the client state using 'resetStore' #1509

oavasilcai opened this issue Mar 28, 2017 · 6 comments

Comments

@oavasilcai
Copy link

Not sure if this is actually a bug but more of behaviour issue, we use resetStore to clear the state on user logout. However, active queries on that page are being sent once resetStore is called.

The queries made require authentication on the backend, so once logout is made they respond with a 401.

I've already submitted a PR with a possible solution, just not sure how the apollo team wants to go about it: #1487

@Poincare
Copy link
Contributor

This is currently intended behavior as far as I know.

If resetStore didn't refetch queries that are active on your page, then your cache would be left in state that may display information pre-resetStore. This is obviously bad (e.g. if you resetStore on logout).

@oavasilcai
Copy link
Author

There is no information in pre-resetStore - and I would prefer that over refetching queries and getting 403's because the token/cookies are invalid.

The usecase makes it more difficult for us because this piece of our app is kind of a 'microservice' and logouts navigates away from it's own 'micro-domain'

@oavasilcai
Copy link
Author

@Poincare also, in the PR I've added an option to resetStore to be able to not refetch, default behaviour is still to run active queries. PR here: #1487

@helfer
Copy link
Contributor

helfer commented May 2, 2017

I think this should be fixed in react-apollo now, which was keeping the observable queries alive even when they weren't used any more.

@helfer helfer closed this as completed May 2, 2017
@oavasilcai
Copy link
Author

hi helfer, got a link to the PR ?

@helfer
Copy link
Contributor

helfer commented May 4, 2017

@oavasilcai #1636 and the PR that references it in react-apollo. It should be shipped in react-apollo@^1.2.0.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants