apollo-client
apollo-client copied to clipboard
Loading property on refetched queries is not updated on resetStore
Intended outcome:
When using client.resetStore(), all queries are refetched, I expect the loading property from useQuery to be updated to true then false
Actual outcome:
The loading property is never updated after a client.resetStore()
How to reproduce the issue:
I'm using this after a workspace switch to refetch all the queries.
So you could just have a regular "meQuery", do a client.resetStore check if loading passes at "true"
const { loading, error, data } = useQuery(GET_ME)
Versions
"@apollo/client": "3.4.13"
I think I am experiencing a similar problem.
I have a query like this:
query FetchExample(
$vl1: ID!
$vl3: ID!
$vl4: [ID!]!
) {
level1(id: $vl1) {
id
level2 {
level3(id: $vl3) {
id
level4(filters: { userIds: $vl4 }) {
level5 {
edges {
node {
id
value
}
}
}
}
}
}
}
}
InMemoryCache defined like so:
const cache = new InMemoryCache({
typePolicies: {
level3: {
fields: {
level4: {merge: true},
},
},
},
});
The query works just fine for the first time. I have a component that renders useQuery react hook and puts a result of it into a ContextProvider.
But later, when I update children of level4 entity, I remove level3 entity from cache by doing so:
const client = useApolloClient();
client.cache.evict({
id: `level3:${vl3}`,
});
client.cache.gc();
I see that Apollo run the query automatically, which is quite predictable. But a result of useQuery hook is not changed until response received. So, there is no change in a loading state.
What am I doing wrong of may be there is some trick?
Version:
"@apollo/client": "^3.6.9",
Hi all, I'm doing some housekeeping. This might be similar to / a duplicate of https://github.com/apollographql/apollo-client/issues/8995 but I'll leave both issues open for now. Thanks for your patience!
Just fo your information, to me it's not a problem anymore. I realized that I can use notifyOnNetworkStatusChange: true, property to resolve my issue.
@MorganeLecurieux I think @boonya's comment is correct. Can you try notifyOnNetworkStatusChange: true and see if this resolves your issue?
Hi all - I believe @boonya's comment above is correct, too. I'll go ahead and close out this issue, but @MorganeLecurieux if you have any other information here feel free to comment and I can re-open it. Thanks!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.