You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Normally, you will not interact with the MutationCache directly and instead use the `QueryClient`.**
9
+
10
+
```js
11
+
import { MutationCache } from'react-query'
12
+
13
+
constmutationCache=newMutationCache()
14
+
```
15
+
16
+
Its available methods are:
17
+
18
+
-[`getAll`](#mutationcachegetall)
19
+
-[`subscribe`](#mutationcachesubscribe)
20
+
-[`clear`](#mutationcacheclear)
21
+
22
+
## `mutationCache.getAll`
23
+
24
+
`getAll` returns all mutations within the cache.
25
+
26
+
> Note: This is not typically needed for most applications, but can come in handy when needing more information about a mutation in rare scenarios
27
+
28
+
```js
29
+
constmutations=mutationCache.getAll()
30
+
```
31
+
32
+
**Returns**
33
+
34
+
-`Mutation[]`
35
+
- Mutation instances from the cache
36
+
37
+
## `mutationCache.subscribe`
38
+
39
+
The `subscribe` method can be used to subscribe to the mutation cache as a whole and be informed of safe/known updates to the cache like mutation states changing or mutations being updated, added or removed.
The `invalidateQueries` method can be used to invalidate and refetch single or multiple queries in the cache based on their query keys or any other functionally accessible property/state of the query. By default, all matching queries are immediately marked as invalid and active queries are refetched in the background.
0 commit comments