-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
I'd like to centralize the handling of errors for queries and to centralize handling of mutations' promises.
I've read docs regarding using a Redux Middleware for Global Errors but I'm seeking a more refined behavior thus asking here for suggestions.
I'm using React and Typescript.
The wanted behaviours are:
- On Foreground Query failures, toast an error message. Queries from Polling should be ignored as considered Background.
- On Mutations, display a 'loading' toast on start, a success/error toast once promise is completed.
- Should be compatible with Retry HoF for baseQuery
- Should not apply to other Thunk actions that are not from RTKQ (e.g Slices Thunks)
- Can opt-out of these default behaviours with meta flags set either at Hook usage or at Endpoint definition
How can:
- Identify Query vs Mutation in either Middleware or BaseQuery
- Identify a 'background' vs a first request in a Polling/Refresh scenario
- Identify a RTKQ Thunk from non-RTKQ one in Middleware
Any suggestions/pointers would help.
Metadata
Metadata
Assignees
Labels
No labels