From 4d383c6fc88582bb71c7ca77d9f860a99c815893 Mon Sep 17 00:00:00 2001 From: Jesse Brault Date: Wed, 14 Aug 2024 09:32:17 -0500 Subject: [PATCH] Automatic token refrehs for mutation error. --- src/AuthAwareQueryClientProvider.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/AuthAwareQueryClientProvider.tsx b/src/AuthAwareQueryClientProvider.tsx index 6459973..32c175b 100644 --- a/src/AuthAwareQueryClientProvider.tsx +++ b/src/AuthAwareQueryClientProvider.tsx @@ -49,6 +49,13 @@ const AuthAwareQueryClientProvider = ({ children }: React.PropsWithChildren) => () => new QueryClient({ defaultOptions: { + mutations: { + onError(error) { + if (error instanceof ExpiredTokenError) { + doRefresh() + } + } + }, queries: { retry(failureCount, error) { if (