@@ -29,7 +29,8 @@ Some of the TS types on this page are pseudocode to illustrate intent, as the ac
29
29
const updateQueryData = (
30
30
endpointName : string ,
31
31
args : any ,
32
- updateRecipe : (draft : Draft <CachedState >) => void
32
+ updateRecipe : (draft : Draft <CachedState >) => void ,
33
+ updateProvided ? : boolean
33
34
) => ThunkAction < PatchCollection , PartialState, any, AnyAction>;
34
35
35
36
interface PatchCollection {
@@ -43,6 +44,7 @@ interface PatchCollection {
43
44
- ` endpointName ` : a string matching an existing endpoint name
44
45
- ` args ` : an argument matching that used for a previous query call, used to determine which cached dataset needs to be updated
45
46
- ` updateRecipe ` : an Immer ` produce ` callback that can apply changes to the cached state
47
+ - ` updateProvided ` : a boolean indicating whether the endpoint's provided tags should be re-calculated based on the updated cache. Defaults to ` false ` .
46
48
47
49
#### Description
48
50
@@ -155,14 +157,16 @@ await dispatch(
155
157
const patchQueryData = (
156
158
endpointName : string ,
157
159
args : any
158
- patches : Patch []
160
+ patches : Patch [],
161
+ updateProvided ? : boolean
159
162
) => ThunkAction < void , PartialState, any, AnyAction>;
160
163
```
161
164
162
165
- ** Parameters**
163
166
- ` endpointName ` : a string matching an existing endpoint name
164
167
- ` args ` : a cache key, used to determine which cached dataset needs to be updated
165
168
- ` 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 )
169
+ - ` updateProvided ` : a boolean indicating whether the endpoint's provided tags should be re-calculated based on the updated cache. Defaults to ` false ` .
166
170
167
171
#### Description
168
172
@@ -229,42 +233,42 @@ dispatch(api.util.prefetch('getPosts', undefined, { force: true }))
229
233
```
230
234
231
235
### ` selectInvalidatedBy `
232
-
236
+
233
237
#### Signature
234
-
238
+
235
239
``` ts no-transpile
236
- function selectInvalidatedBy(
237
- state : RootState ,
238
- tags : ReadonlyArray <TagDescription <string >>
239
- ): Array <{
240
- endpointName: string
241
- originalArgs: any
242
- queryCacheKey: QueryCacheKey
243
- }>
240
+ function selectInvalidatedBy(
241
+ state : RootState ,
242
+ tags : ReadonlyArray <TagDescription <string >>
243
+ ): Array <{
244
+ endpointName: string
245
+ originalArgs: any
246
+ queryCacheKey: QueryCacheKey
247
+ }>
244
248
```
245
-
249
+
246
250
- ** Parameters **
247
251
- ` state ` : the root state
248
252
- ` 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 .
249
253
- ` [TagType] `
250
254
- ` [{ type: TagType }] `
251
255
- ` [{ type: TagType, id: number | string }] `
252
-
256
+
253
257
#### Description
254
-
258
+
255
259
A function that can select query parameters to be invalidated.
256
-
260
+
257
261
The function accepts two arguments
258
- - the root state and
259
- - the cache tags to be invalidated.
260
-
262
+ - the root state and
263
+ - the cache tags to be invalidated.
264
+
261
265
It returns an array that contains
262
- - the endpoint name ,
263
- - the original args and
264
- - the queryCacheKey .
265
-
266
+ - the endpoint name ,
267
+ - the original args and
268
+ - the queryCacheKey .
269
+
266
270
#### Example
267
-
271
+
268
272
` ` ` ts no-transpile
269
273
dispatch(api.util.selectInvalidatedBy(state, ['Post']))
270
274
dispatch(api.util.selectInvalidatedBy(state, [{ type: 'Post', id: 1 }]))
0 commit comments