Skip to content

How to Update Cache Data from Middleware? #3633

Answered by EskiMojo14
User6531 asked this question in Q&A
Discussion options

You must be logged in to vote

The only comment i'd make is that updateQueryData uses Immer, so you can mutate the parameter:

          dispatch(
            applicationApi.util.updateQueryData(
              "getApplications",
              undefined,
              (prevApplications: TApplication[]) => { prevApplications.push(res) },
            ),
          );

Other than that, it's worth noting that the second parameter needs to match the argument used, and the cache entry needs to already be in state (i.e. you need something to be subscribed to it).

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@User6531
Comment options

@User6531
Comment options

@EskiMojo14
Comment options

@User6531
Comment options

Answer selected by User6531
Comment options

You must be logged in to vote
2 replies
@User6531
Comment options

@EskiMojo14
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants