T
TanStack14mo ago
flat-fuchsia

QueryClient configuration: Invalidating all queries when a 401 is returned (solid-query)

Hi, Is there a way to do something like:
import { QueryClient } from '@tanstack/solid-query';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
onError: async (error: any) => { // onError exists on on mutations
if (error.status === 401) {
await queryClient.invalidateQueries();
}
},
},
...
import { QueryClient } from '@tanstack/solid-query';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
onError: async (error: any) => { // onError exists on on mutations
if (error.status === 401) {
await queryClient.invalidateQueries();
}
},
},
...
1 Reply
manual-pink
manual-pink14mo ago
Automatic Query Invalidation after Mutations
Even though there is nothing built into React Query, it doesn't need a lot of code to implement automatic query invalidation in user-land thanks to the global cache callbacks.

Did you find this page helpful?