MCPcopy Create free account
hub / github.com/TanStack/query / clear

Method clear

packages/query-core/src/mutationCache.ts:262–271  ·  view source on GitHub ↗

* Removes all mutations from the cache. * @example * ```ts * const mutationCache = queryClient.getMutationCache() * * mutationCache.clear() * ```

()

Source from the content-addressed store, hash-verified

260 * ```
261 */
262 clear(): void {
263 notifyManager.batch(() => {
264 const mutations = this.getAll()
265 this.#mutations.clear()
266 this.#scopes.clear()
267 mutations.forEach((mutation) => {
268 this.notify({ type: 'removed', mutation })
269 })
270 })
271 }
272
273 /**
274 * Returns all mutations within the cache.

Callers

nothing calls this directly

Calls 2

getAllMethod · 0.95
notifyMethod · 0.95

Tested by

no test coverage detected