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.

How to make the query optimistic?

See original GitHub issue

I can’t figure out, how to make the queries optimistic. I’m using the API like this:

const deleteContact = useMutation(gql(mutations.deleteContact));

handleClick = async id => {
  const res = await deleteContact({ variables: { input: { id } } });
  console.log('Delete Contact', res);
}

And res has Symbol(isOptimistic): false. How can I make that true?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
lukaslueckecommented, Mar 18, 2019

Great! Yeah, the manual cache update stuff always feels a bit cumbersome, even with “plain” Apollo.

Do you think I could use the buildMutation helper (from the link of my last comment) if I pass it client from useApolloClient? That might work, but then you would bypass the mutation hook altogether 😉

1reaction
janhesterscommented, Mar 18, 2019

@lukasluecke It works! It’s super verbose, but I guess that is the best that it can be at the moment. Thank you for your help 🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Query Tutorial - 24 - Optimistic Updates - YouTube
Courses - https://learn.codevolution.dev/ Support UPI - https://support.codevolution.dev/ Support PayPal ...
Read more >
Optimistic Updates | TanStack Query Docs
To do this, useMutation 's onMutate handler option allows you to return a value that will later be passed to both onError and...
Read more >
Optimistic UI With React Query - Mehdi Namvar - Medium
It is really easy to use. I love React Query! Not only you can control every detail of how you fetch, cache, and...
Read more >
Optimistic mutation results - Apollo GraphQL Docs
When viewing the example, try adding an item to the to-do list. Notice that the item appears in the list instantly, even though...
Read more >
React Query and optimistic updates - Daily Dev Tips
React Query optimistic updates permalink · mutation gets triggers · onMutate temporary adds the new Pokemon to the list · mutation returns a...
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