-
Notifications
You must be signed in to change notification settings - Fork 786
Component won´t rerender with new data after client.resetStore() #807
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to React Apollo! |
Bringing in an issue from AC to see if we can improve this: Intended outcome: resetStore clears the Apollo data Actual outcome: How to reproduce the issue: error repo: https://github.com/stantoncbradley/apollo-reset-store
Our actual use case is a user signing out of our app. We noticed if another user logs in and one of the queries fails, data from the last user displays! It was never cleared!!!! |
really like to see this get fixed! it's imperative that we completely clear our user data after the user logs out!!! 🙏 |
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo! |
this is still a big issue. We are locked into |
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo! |
@jbaxleyiii this is still an issue as far as I'm aware. related to #858 and #890 too |
Still an issue also in apollo-client 2.0 beta. |
Please add this to https://github.com/apollographql/apollo-client/milestone/9. |
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo! |
This issue has been automatically closed because it has not had recent activity after being marked as no recent activyt. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to React Apollo! |
I believe this is still a problem in 2.0 and should be re-opened. |
this is a really big issue and I'm afraid it's not well known, nor getting the attention it deserves. To be clear, react-apollo isn't properly clearing user data and there are scenarios where react-apollo can leak (sensitive) data after the store has been "cleared". If more people realized they have this known issue in production, I don't think they would be happy with Apollo |
@stantoncbradley this is on my radar for my next focus on cleaning up react-apollo 👍 |
Thanks @jbaxleyiii looking forward to it 😄 |
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo! |
Pretty sure this is still an issue |
Any workarounds for this? I tried manually recreating the client cache to no avail. |
@jbaxleyiii hopefully this is still on your radar? Major security concern for us. We can't upgrade til this is fixed |
@gpoitch Currently you can use |
I created a failing test for this here: n1ru4l@e358061 Edit: I am not 100% sure but I think this might be an issue that could be solved in apollo-client. Edit 2: I digged into the apollo-client codebase and found some things: When you create an observableQuery using const data = {
me: {
id: 1,
__typename: 'Person',
login: 'peterpan'
},
};
const link = new ApolloLink(() => {
return new Observable(observer => {
setTimeout(() => {
observer.next({ data });
observer.complete();
}, 10)
});
});
const client = new ApolloClient({
link,
cache: new InMemoryCache({}),
});
const query = gql`
query me {
me {
id
login
}
}
`
const observableQuery = client.watchQuery({
query,
});
observableQuery.subscribe({
next: console.log,
})
setTimeout(() => client.resetStore(), 100);
// first console.log call
{
data: { me: { id: 1, login: 'peterpan', __typename: 'Person' } },
loading: false,
networkStatus: 7,
stale: false
}
// second console.log call
{
data: { me: { id: 1, login: 'peterpan', __typename: 'Person' } },
loading: false,
networkStatus: 7,
stale: false
} This might be intended, however I do not understand why there is never a loading "state" published by the observable. Would be nice if anyone could explain this.. The step that prevents this data to be published is here: https://github.com/apollographql/apollo-client/blob/master/packages/apollo-client/src/core/QueryManager.ts#L460 Edit 3: Seems like Maybe this is already another issue? |
Does |
|
Are there any updates on this one? Its been over a year and this issue still seems fairly active Is there a best-practice workaround for clearing the cache to defaults and triggering query re-renders when, for example, a user logs out? I'm using apollo-link-state to store a local logged-in status which I'm querying in a container, then using the results of that query to conditionally route/redirect, but right now my query isn't being re-rendered, at least with |
Here's a current repro of a https://codesandbox.io/s/72x4okp5m1 Versions |
React Apollo has been refactored to use React Hooks behind the scenes for everything, which means a lot has changed since this issue was opened (and a lot of outstanding issues have been resolved). We'll close this issue off, but please let us know if you're still encountering this problem using React Apollo >= 3.1.0. Thanks! |
Love apollo, but I have this problem...
Steps to Reproduce
Buggy Behavior
The component is not rerendered with a clared store. In this case I had logged out the user so the query should give me {me: null} but it still gives me the old object.
Expected Behavior
It should give me a null object for "me" since I´ve logged out and cleared the store like the docs say.
Version
The text was updated successfully, but these errors were encountered: