T
TanStack3y ago
ambitious-aqua

Invalidating Queries doesn't send a request

I'm using TRPC, which is using react-query. For some reason getWebsites does not invalidate when invalidate is called. TRPC's invalidate is using queryClient.invalidateQueries I have the following code snippet:
const websites = trpc.website.getWebsites.useQuery(undefined, {
enabled: isAuthenticated,
});
const updateWebsite = trpc.website.updateWebsite.useMutation({
onSuccess: async () => {
await utils.website.getWebsites.invalidate();
// this doesnt send a request for some reason, even if I removed the enabled option on websites
},
});
const websites = trpc.website.getWebsites.useQuery(undefined, {
enabled: isAuthenticated,
});
const updateWebsite = trpc.website.updateWebsite.useMutation({
onSuccess: async () => {
await utils.website.getWebsites.invalidate();
// this doesnt send a request for some reason, even if I removed the enabled option on websites
},
});
No description
2 Replies
optimistic-gold
optimistic-gold3y ago
Disabled queries don't get refetched with invalidation
ambitious-aqua
ambitious-aquaOP3y ago
It does not refetch even if I remove the enabled option. Fixed: Another context was conflicting with TRPC because both uses react-query.

Did you find this page helpful?