diff --git a/docs/rtk-query/api/created-api/api-slice-utils.mdx b/docs/rtk-query/api/created-api/api-slice-utils.mdx index 6471d812e9..cae293e840 100644 --- a/docs/rtk-query/api/created-api/api-slice-utils.mdx +++ b/docs/rtk-query/api/created-api/api-slice-utils.mdx @@ -29,7 +29,8 @@ Some of the TS types on this page are pseudocode to illustrate intent, as the ac const updateQueryData = ( endpointName: string, args: any, - updateRecipe: (draft: Draft) => void + updateRecipe: (draft: Draft) => void, + updateProvided?: boolean ) => ThunkAction; interface PatchCollection { @@ -43,6 +44,7 @@ interface PatchCollection { - `endpointName`: a string matching an existing endpoint name - `args`: an argument matching that used for a previous query call, used to determine which cached dataset needs to be updated - `updateRecipe`: an Immer `produce` callback that can apply changes to the cached state + - `updateProvided`: a boolean indicating whether the endpoint's provided tags should be re-calculated based on the updated cache. Defaults to `false`. #### Description @@ -155,7 +157,8 @@ await dispatch( const patchQueryData = ( endpointName: string, args: any - patches: Patch[] + patches: Patch[], + updateProvided?: boolean ) => ThunkAction; ``` @@ -163,6 +166,7 @@ const patchQueryData = ( - `endpointName`: a string matching an existing endpoint name - `args`: a cache key, used to determine which cached dataset needs to be updated - `patches`: an array of patches (or inverse patches) to apply to cached state. These would typically be obtained from the result of dispatching [`updateQueryData`](#updatequerydata) + - `updateProvided`: a boolean indicating whether the endpoint's provided tags should be re-calculated based on the updated cache. Defaults to `false`. #### Description @@ -229,42 +233,42 @@ dispatch(api.util.prefetch('getPosts', undefined, { force: true })) ``` ### `selectInvalidatedBy` - + #### Signature - + ```ts no-transpile - function selectInvalidatedBy( - state: RootState, - tags: ReadonlyArray> - ): Array<{ - endpointName: string - originalArgs: any - queryCacheKey: QueryCacheKey - }> +function selectInvalidatedBy( + state: RootState, + tags: ReadonlyArray> +): Array<{ + endpointName: string + originalArgs: any + queryCacheKey: QueryCacheKey +}> ``` - + - **Parameters** - `state`: the root state - `tags`: a readonly array of invalidated tags, where the provided `TagDescription` is one of the strings provided to the [`tagTypes`](../createApi.mdx#tagtypes) property of the api. e.g. - `[TagType]` - `[{ type: TagType }]` - `[{ type: TagType, id: number | string }]` - + #### Description - + A function that can select query parameters to be invalidated. - + The function accepts two arguments - - the root state and - - the cache tags to be invalidated. - +- the root state and +- the cache tags to be invalidated. + It returns an array that contains - - the endpoint name, - - the original args and - - the queryCacheKey. - +- the endpoint name, +- the original args and +- the queryCacheKey. + #### Example - + ```ts no-transpile dispatch(api.util.selectInvalidatedBy(state, ['Post'])) dispatch(api.util.selectInvalidatedBy(state, [{ type: 'Post', id: 1 }]))