-
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
Query refetched after a mutation doesn't trigger re-render #9270
Comments
Bump, I can confirm that this is the case using the (pseudo)code below using version const [mutate] = useSomeMutation({ // Generated hook by graphql-codegen
refetchQueries: [
{query: GetSomeDocument},
],
});
mutate(); // GetSomeDocument doesn't get refetched Edit: actually, the actual query isn't even triggered, and of course a re-render doesn't happen as well. Maybe related to #9597? |
I get the same with the following on 3.6.2, rolling back to 3.5.10 fixes the issue
|
Same issue for me. |
3.5.10 was the last version where mutation refetchQueries worked for me. I am on React 18, is that the problem? |
@mfurniss Probably not, we’re still on React 17. Forgot to point that out in my earlier reply. |
I tried using both a list of strings and objects. Same result. With 3.6.2 no refetch occurs on any query. I'll roll back to 3.5.10 for now. |
no refetch with client object as well using array with documentNode parsed by gql and string name as variables for refetch arguments. |
Experience the same issue with the latest version Reverting back to |
As of 3.6.8 the issue is fixed for me. Thanks! |
@mfurniss thanks for sharing that! @KoenBrouwer can you try upgrading your client to |
@jpvajda Looks like we're at |
@KoenBrouwer Great news! Thanks for confirming. |
This problem does not seem to have been solved. I am using v3.6.8 and the re-fetch does not run! |
Let’s update to 3.6.9, cause it 100% worked for me. Mind sharing some of your code as well? I’d be happy to help out. |
Seeing strange behavior where
useQuery
hook doesn't trigger re-render when the query is included insideuseMutation
'srefetchQueries
array as an object with no variables.For example, when I specify a query to be refetched after a mutation occurs like this:
refetchQueries: [{ query: DocumentNode }]
I am seeing the following results: mutation succeeds, refetch query happens, the cache is updated correctly but UI is not.
However, both
refetchQueries: ['QueryName']
andrefetchQueries: [DocumentNode]
work as expected.Side note: the documentation for
refetchQueries
array is inconsistent about the element type:https://www.apollographql.com/docs/react/data/mutations/#refetching-queries
https://www.apollographql.com/docs/react/data/mutations/#refetchqueries
Versions
System:
OS: macOS 12.0.1
Binaries:
Node: 16.8.0
Yarn: 1.22.15
npm: 8.0.0
Browsers:
Chrome: 96.0.4664.110
Firefox: 85.0.2
Safari: 15.1
The text was updated successfully, but these errors were encountered: