Open History to see the last commit
1import { MutationCache as MC } from '@tanstack/query-core'
2import { cloneDeepUnref } from './utils'
3import type {
4 DefaultError,
5 Mutation,
6 MutationFilters,
7} from '@tanstack/query-core'
8import type { MaybeRefDeep } from './types'
9β
10/**
11 * Vue-aware subclass of `@tanstack/query-core`'s `MutationCache`.
12 * `find`/`findAll` also accept a {@link MaybeRefDeep} filters object, so `ref`s
13 * can be passed directly without unwrapping. Access it via
14 * `queryClient.getMutationCache()` β `QueryClient` constructs one of these by
15 * default.
16 */
17export class MutationCache extends MC {
18 override find<
19 TData = unknown,
20 TError = DefaultError,
21 TVariables = any,
22 TOnMutateResult = unknown,
23 >(
24 filters: MaybeRefDeep<MutationFilters>,
25 ): Mutation<TData, TError, TVariables, TOnMutateResult> | undefined {
26 return super.find(cloneDeepUnref(filters))
27 }
28β
29 override findAll(
30 filters: MaybeRefDeep<MutationFilters> = {},
31 ): Array<Mutation> {
32 return super.findAll(cloneDeepUnref(filters))
33 }
34}