How to refetch query after mutation?

I now this is very basic task but seriously i don't know how to do it.
5 Replies
barry
barry2y ago
Pass a callback to onSuccess in the mutation hook, inside of that you just run query.refetch() or you invalidate it which you can see how to on docs
vilchy ✓
vilchy ✓2y ago
it works now, thanks
stanisław
stanisław2y ago
Does refetch do basically the same as invalidate? If i have a direct access to useQuery is it better to use refetch? Or there is no differnce
isaac_way
isaac_way2y ago
Refetch will force a loading state which is a way different UX. Invalidate does a background refetch
barry
barry2y ago
good to know
Want results from more Discord servers?
Add your server