question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v3.0.0-beta.16 useQuery returns stale data when in same component as useMutation

See original GitHub issue

In 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cbergmillercommented, Jan 23, 2020

@hwillson The problem is fixed now (tested with 3.0.0-beta.24). Thanks to the Apollo team!

0reactions
hwillsoncommented, Jan 23, 2020

Great to hear @cbergmiller - thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found