How to refetch based on different event

I have a procedure that fetches all products, I have another one that deletes a project given it's ID, these two are used on the same page, how can tell tRPC to rerun the allProducts request when a delete happens. currently I need to refresh to see the product get deleted, in case that's not what's supposed to happen please tell me. I am using the pages router and tRPC v10
Aleed.dev279d ago
i know of two ways . first is to invalidate the cahce result . second react query provide a refetch function that you can call when ever their is a mutation
Aleed.dev279d ago
Query Invalidation | TanStack Query Docs
Waiting for queries to become stale before they are fetched again doesn't always work, especially when you know for a fact that a query's data is out of date because of something the user has done. For that purpose, the QueryClient has an invalidateQueries method that lets you intelligently mark queries as stale and potentially refetch them too!