Skip to content

Invalidate a tag on every mutation from code generated RTK Query base #3926

Closed Answered by programm-ingovals
programm-ingovals asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up going for the middleware

export const validationMiddleware: Middleware =
  (api: MiddlewareAPI) => (next) => (action) => {
    if (isFulfilled(action) && action.meta.arg.type === 'mutation') {
      api.dispatch(rtkApi.util.invalidateTags(['Validation']))
    }

    return next(action)
  }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by programm-ingovals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant