rtk-incubator / rtk-query

Data fetching and caching addon for Redux Toolkit
https://redux-toolkit.js.org/rtk-query/overview
MIT License
626 stars 31 forks source link

Mutation does not invalidate #226

Closed sumeyradavran closed 3 years ago

sumeyradavran commented 3 years ago

Hello 👋 I want to say great job for all you did. I am closely following updates and I am planning on moving to rtk-query.

I am playing around and I think I need some help regarding invalidation. Here is a codesandbox link and I am trying to invalidate the query and refetch getAll endpoint. This is the basic mechanism I followed on my project and it is not working in the project also. https://codesandbox.io/s/crazy-ives-y4wtz?file=/src/pokemonApi.ts

phryneas commented 3 years ago

Thanks for the report. It looks like you are doing everything right from your side - we'll look into it!

phryneas commented 3 years ago

Okay, I am sorry, I was completely blind here and missed the obvious. You forgot to add the middleware.

  configureStore({
    reducer: {
      [pokemonApi.reducerPath]: pokemonApi.reducer
    },
+    middleware: getDefaultMiddleware => getDefaultMiddleware().concat(pokemonApi.middleware)
  });