Skip to content

Conversation

AntoLC
Copy link
Collaborator

@AntoLC AntoLC commented Jul 24, 2025

Purpose

To capture a 401 we were using onError in the queryClient default mutation options.
The problem is this way does not capture globally the onError, if a mutation uses as well is own onError, it will override the default one, causing the 401 to not be captured anymore.

Proposal

We now use MutationCache, which allows us to capture globally the onError, even if a mutation has its own onError defined, this global one will still be called.

@AntoLC AntoLC self-assigned this Jul 24, 2025
@AntoLC AntoLC added bug Something isn't working frontend labels Jul 24, 2025
@AntoLC AntoLC force-pushed the fix/401-redirection branch from a6140f8 to be1db39 Compare July 24, 2025 09:45
@AntoLC AntoLC requested a review from lunika July 24, 2025 10:19
To capture a 401 we were using "onError" in the
queryClient default mutation options. The problem
is this way does not capture globally the onError,
if a mutation uses as well is own "onError", it will
override the default one, causing the 401 to
not be captured anymore.
We now use MutationCache, which allows us to
capture globally the onError, even if a mutation
has its own "onError" defined, this global one will
still be called.
@AntoLC AntoLC force-pushed the fix/401-redirection branch from be1db39 to 04273c3 Compare July 25, 2025 10:04
@AntoLC AntoLC merged commit 04273c3 into main Jul 25, 2025
20 of 21 checks passed
@AntoLC AntoLC deleted the fix/401-redirection branch July 25, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants