diff --git a/docs/rtk-query/api/createApi.mdx b/docs/rtk-query/api/createApi.mdx index 89f2fe5350..8dc5d05f88 100644 --- a/docs/rtk-query/api/createApi.mdx +++ b/docs/rtk-query/api/createApi.mdx @@ -164,7 +164,8 @@ export type QueryDefinition< TagTypes, ResultType, QueryArg, - BaseQueryError + BaseQueryError, + BaseQueryMeta > keepUnusedDataFor?: number @@ -228,7 +229,13 @@ export type MutationDefinition< extraOptions?: BaseQueryExtraOptions - invalidatesTags?: ResultDescription + invalidatesTags?: ResultDescription< + TagTypes, + ResultType, + QueryArg, + BaseQueryError, + BaseQueryMeta + > onQueryStarted?( arg: QueryArg, diff --git a/docs/rtk-query/usage-with-typescript.mdx b/docs/rtk-query/usage-with-typescript.mdx index 259d391193..b9c333d8e3 100644 --- a/docs/rtk-query/usage-with-typescript.mdx +++ b/docs/rtk-query/usage-with-typescript.mdx @@ -398,6 +398,7 @@ When using the function notation, both the `providesTags` and `invalidatesTags` - result: `ResultType` | `undefined` - The result returned by a successful query. The type corresponds with `ResultType` as [supplied to the built endpoint](#typing-query-and-mutation-endpoints). In the error case for a query, this will be `undefined`. - error: `ErrorType` | `undefined` - The error returned by an errored query. The type corresponds with `Error` as [supplied to the `baseQuery` for the api](#typing-a-basequery). In the success case for a query, this will be `undefined`. - arg: `QueryArg` - The argument supplied to the `query` property when the query itself is called. The type corresponds with `QueryArg` as [supplied to the built endpoint](#typing-query-and-mutation-endpoints). +- meta: `MetaType` | `undefined` - The optional `meta` value returned by `baseQuery` A recommended use-case with `providesTags` when a query returns a list of items is to provide a tag for each item in the list using the entity ID, as well as a 'LIST' ID tag (see [Advanced Invalidation with abstract tag IDs](./usage/automated-refetching.mdx#advanced-invalidation-with-abstract-tag-ids)). diff --git a/docs/rtk-query/usage/automated-refetching.mdx b/docs/rtk-query/usage/automated-refetching.mdx index 38be5f90a0..27e28540f5 100644 --- a/docs/rtk-query/usage/automated-refetching.mdx +++ b/docs/rtk-query/usage/automated-refetching.mdx @@ -44,7 +44,14 @@ _see also: [invalidatesTags API reference](../api/createApi.mdx#invalidatestags) A _mutation_ can _invalidate_ specific cached data based on the tags. Doing so determines which cached data will be either refetched or removed from the cache. -The `invalidatesTags` argument can either be an array of `string` (such as `['Post']`), `{type: string, id?: string|number}` (such as `[{type: 'Post', id: 1}]`), or a callback that returns such an array. That function will be passed the result as the first argument, the response error as the second argument, and the argument originally passed into the `query` method as the third argument. Note that either the result or error arguments may be undefined based on whether the mutation was successful or not. +The `invalidatesTags` argument can either be an array of `string` (such as `['Post']`), `{type: string, id?: string|number}` (such as `[{type: 'Post', id: 1}]`), or a callback that returns such an array. That function will be passed: + +1. the result as the first argument, +1. the response error as the second argument, +1. the argument originally passed into the `query` method as the third argument, +1. and any optional `meta` property resolved by `baseQuery`. + +Note that either the result or error arguments may be undefined based on whether the mutation was successful or not. ## Cache tags