title: Redux Toolkit Query: Reduce state from "mutation" response
body: <p>Let's say I have an RESTish API to manage &quot;posts&quot;.</p>
  <ul>
  <li><code>GET /posts</code> returns all posts</li>
  <li><code>PATCH /posts:id</code> updates a post and responds with new record data</li>
  </ul>
  <p>I can implement this using RTK query via something like this:</p>
  <pre class="lang-js prettyprint-override"><code>const TAG_TYPE = 'POST';
  
  // Define a service using a base URL and expected endpoints
  export const postsApi = createApi({
    reducerPath: 'postsApi',
    tagTypes: [TAG_TYPE],
    baseQuery,
    endpoints: (builder) =&gt; ({
      getPosts: builder.query&lt;Form[], string&gt;({
        query: () =&gt; `/posts`,
        providesTags: (result) =&gt;
          [
            { type: TAG_TYPE, id: 'LIST' },
          ],
      }),
      updatePost: builder.mutation&lt;any, { formId: string; formData: any }&gt;({
        // note: an optional `queryFn` may be used in place of `query`
        query: (data) =&gt; ({
          url: `/post/${data.formId}`,
          method: 'PATCH',
          body: data.formData,
        }),
        // this causes a full re-query.  
        // Would be more efficient to update state based on resp.body
        invalidatesTags: [{ type: TAG_TYPE, id: 'LIST' }],
      }),
    }),
  });
  </code></pre>
  <p>When <code>updatePost</code> runs, it invalidates the <code>LIST</code> tag which causes <code>getPosts</code> to run again.</p>
  <p>However, since the <code>PATCH</code> operation responds with the new data itself, I would like to avoid making an additional server request and instead just update my reducer state for that specific record with the content of <code>response.body</code>.</p>
  <p>Seems like a common use case, but I'm struggling to find any documentation on doing something like this.</p>