How to fetch data and don't update the results after mutation
See original GitHub issueHello guys,
I have a page that needs to verify if any applications were created by the user to show or not a content. If the user has one or more applications, I redirect him to the applications page. If the user doesn’t have application, a tutorial will start to create a first application.
When the user creates an application using the tutorial, the lib refetches data and redirect the user, because now he has an application, but the tutorial still has some additional steps after this creation.
Can I prevent refetching applications in this situation? You can find the snippet below:
export default function Dashboard() {
const { data, isLoading } = useQuery(['apps']);
if (isLoading) return <Loading />;
if (data.length > 0) {
/* function to redirect users here */
return <Loading />;
}
return <Tutorial />;
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Mutations in Apollo Client - Apollo GraphQL Docs
This article demonstrates how to send updates to your GraphQL server with the useMutation hook. You'll also learn how to update the Apollo...
Read more >How to update the Apollo Client's cache after a mutation
Basically, you should make your mutation results have all of the data necessary to update the queries previously fetched.
Read more >RefetchQueries after mutation not updating UI, yet network tab ...
Intended outcome: I'm trying to authenticate a user and have it update my navbar (which uses the same query) to show different options ......
Read more >How to update local data after mutation? - Stack Overflow
I just simply want to update local state and add new item to an observable query result after addItem mutation, without using refetchQueries...
Read more >Updates from Mutation Responses | TanStack Query Docs
queryClient = useQueryClient() · const mutation = useMutation({ · : editTodo, · onSuccess: data => { ·.setQueryData(['todo', { id: 5 }], data) ·...
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
Thanks for your contribution @thiagonzalez, and apologies for the delay in getting your PR merged, I didn’t have much time to work on this over the holidays.
Your update is now available on version
0.0.25
.No worries at all, @aribouius. Thank you so much for your incredible work here! Happy new year! 😃