v3.0.0-beta.16 useQuery returns stale data when in same component as useMutation
See original GitHub issueIn an CRUD-Component i have useQuery
and useMutation
hooks:
const {data: locationData} = useQuery(ListLocations, {variables: {siteId}});
const [locationForm, {loading: isSubmitting}] = useMutation(LocationFormMutation);
Intended outcome: After executing the mutation (updating a location entity) the cache should update and useQuery should return a new list of location records with the updated location entity.
Actual outcome: The cache is updated. The query data is not. When i insert the exact same query hook in a parent component, the returned data is updated immediately after the mutation.
Versions “@apollo/client”: “3.0.0-beta.16”, “apollo-link-error”: “2.0.0-beta.0”,
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Mutations in Apollo Client - Apollo GraphQL Docs
When your component renders, useMutation returns a tuple that includes: ... This object is similar to the object returned by the useQuery hook....
Read more >@tannerlinsley/react-query-temp - npm
Hooks for orchestrating, managing, and syncing asynchronous data in ... behavior of hooks like useQuery and useMutation used within it:.
Read more >@apollo/client - Awesome JS
Fix issue where loading remains true after observer.refetch is called repeatedly with different variables when the same data are returned.
Read more >Mutations | TanStack Query Docs
useMutation ({. mutationFn: addTodo,. onMutate: variables => {. // A mutation is about to happen! // Optionally return a context containing data to...
Read more >React Admin v3: Zoom in the Data Layer
So react-admin v3 provides hook alternatives to the Query and Mutation components, called useQuery and useMutation : import { useQuery } from " ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hwillson The problem is fixed now (tested with 3.0.0-beta.24). Thanks to the Apollo team!
Great to hear @cbergmiller - thanks!