Skip to content

Commit 939e8ac

Browse files
committed
task(docs): Updates docs to include result description meta param [#1904]
1 parent 637b0ca commit 939e8ac

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

docs/rtk-query/api/createApi.mdx

+9-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export type QueryDefinition<
164164
TagTypes,
165165
ResultType,
166166
QueryArg,
167-
BaseQueryError<BaseQuery>
167+
BaseQueryError<BaseQuery>,
168+
BaseQueryMeta<BaseQuery>
168169
>
169170

170171
keepUnusedDataFor?: number
@@ -228,7 +229,13 @@ export type MutationDefinition<
228229

229230
extraOptions?: BaseQueryExtraOptions<BaseQuery>
230231

231-
invalidatesTags?: ResultDescription<TagTypes, ResultType, QueryArg>
232+
invalidatesTags?: ResultDescription<
233+
TagTypes,
234+
ResultType,
235+
QueryArg,
236+
BaseQueryError<BaseQuery>,
237+
BaseQueryMeta<BaseQuery>
238+
>
232239

233240
onQueryStarted?(
234241
arg: QueryArg,

docs/rtk-query/usage-with-typescript.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ When using the function notation, both the `providesTags` and `invalidatesTags`
398398
- 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`.
399399
- 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`.
400400
- 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).
401+
- meta: `MetaType` | `undefined` - The optional `meta` value returned by `baseQuery`
401402

402403
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)).
403404

docs/rtk-query/usage/automated-refetching.mdx

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ _see also: [invalidatesTags API reference](../api/createApi.mdx#invalidatestags)
4444

4545
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.
4646

47-
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.
47+
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:
48+
49+
1. the result as the first argument,
50+
1. the response error as the second argument,
51+
1. the argument originally passed into the `query` method as the third argument,
52+
1. and any optional `meta` property resolved by `baseQuery`.
53+
54+
Note that either the result or error arguments may be undefined based on whether the mutation was successful or not.
4855

4956
## Cache tags
5057

0 commit comments

Comments
 (0)