Files
upstream-tanstack-query/docs/framework/vue/reference/classes/MutationCache.md
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

5.9 KiB

id, title
id title
MutationCache MutationCache

Defined in: packages/vue-query/src/mutationCache.ts:15

Vue-aware subclass of @tanstack/query-core's MutationCache. find/findAll also accept a MaybeRefDeep filters object, so refs can be passed directly without unwrapping. Access it via queryClient.getMutationCache() — QueryClient constructs one of these by default.

Extends

  • MutationCache

Constructors

Constructor

new MutationCache(config): MutationCache;

Defined in: packages/query-core/src/mutationCache.ts:129

Parameters

config

MutationCacheConfig = {}

Returns

MutationCache

Inherited from

MC.constructor

Properties

config

config: MutationCacheConfig = {};

Defined in: packages/query-core/src/mutationCache.ts:129

Inherited from

MC.config

listeners

protected listeners: Set<MutationCacheListener>;

Defined in: packages/query-core/src/subscribable.ts:2

Inherited from

MC.listeners

Methods

clear()

clear(): void;

Defined in: packages/query-core/src/mutationCache.ts:236

Removes all mutations from the cache.

Returns

void

Example

const mutationCache = queryClient.getMutationCache()

mutationCache.clear()

Inherited from

MC.clear

find()

find<TData, TError, TVariables, TOnMutateResult>(filters): 
  | Mutation<TData, TError, TVariables, TOnMutateResult>
  | undefined;

Defined in: packages/vue-query/src/mutationCache.ts:16

A slightly more advanced method that can be used to get an existing mutation instance from the cache. If the mutation does not exist, undefined is returned.

This is not typically needed for most applications, but can come in handy when needing more information about a mutation in rare scenarios.

Type Parameters

TData

TData = unknown

TError

TError = Error

TVariables

TVariables = any

TOnMutateResult

TOnMutateResult = unknown

Parameters

filters

MaybeRefDeep<MutationFilters<unknown, Error, unknown, unknown>>

Returns

| Mutation<TData, TError, TVariables, TOnMutateResult> | undefined

See

MutationCache#findAll

Example

const mutationCache = queryClient.getMutationCache()

const mutation = mutationCache.find({ mutationKey: ['addPost'] })

Overrides

MC.find

findAll()

findAll(filters): Mutation<unknown, Error, unknown, unknown>[];

Defined in: packages/vue-query/src/mutationCache.ts:27

An even more advanced method that can be used to get existing mutation instances from the cache that match the given filters. If no mutations match, an empty array is returned.

This is not typically needed for most applications, but can come in handy when needing more information about mutations in rare scenarios.

Parameters

filters

MaybeRefDeep<MutationFilters<unknown, Error, unknown, unknown>> = {}

Returns

Mutation<unknown, Error, unknown, unknown>[]

See

MutationCache#find

Example

const mutationCache = queryClient.getMutationCache()

const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })

Overrides

MC.findAll

getAll()

getAll(): Mutation<unknown, Error, unknown, unknown>[];

Defined in: packages/query-core/src/mutationCache.ts:259

Returns all mutations within the cache.

This is not typically needed for most applications, but can come in handy when needing more information about a mutation in rare scenarios.

Returns

Mutation<unknown, Error, unknown, unknown>[]

Example

const mutationCache = queryClient.getMutationCache()

const mutations = mutationCache.getAll()

Inherited from

MC.getAll

hasListeners()

hasListeners(): boolean;

Defined in: packages/query-core/src/subscribable.ts:19

Returns

boolean

Inherited from

MC.hasListeners

onSubscribe()

protected onSubscribe(): void;

Defined in: packages/query-core/src/subscribable.ts:23

Returns

void

Inherited from

MC.onSubscribe

onUnsubscribe()

protected onUnsubscribe(): void;

Defined in: packages/query-core/src/subscribable.ts:27

Returns

void

Inherited from

MC.onUnsubscribe

subscribe()

subscribe(listener): () => void;

Defined in: packages/query-core/src/subscribable.ts:8

Parameters

listener

MutationCacheListener

Returns

(): void;
Returns

void

Inherited from

MC.subscribe