Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

mutationCache.ts

30 lines991 Bytes

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`. `find`/`findAll` also accept a
12 * {@link MaybeRefDeep} filters object, so `ref`s can be passed directly without unwrapping. Access it via
13 * `queryClient.getMutationCache()` β€” `QueryClient` constructs one of these by default.
14 */
15export class MutationCache extends MC {
16 find<
17 TData = unknown,
18 TError = DefaultError,
19 TVariables = any,
20 TOnMutateResult = unknown,
21 >(
22 filters: MaybeRefDeep<MutationFilters>,
23 ): Mutation<TData, TError, TVariables, TOnMutateResult> | undefined {
24 return super.find(cloneDeepUnref(filters))
25 }
26​
27 findAll(filters: MaybeRefDeep<MutationFilters> = {}): Array<Mutation> {
28 return super.findAll(cloneDeepUnref(filters))
29 }