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

Method add

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

* Adds a mutation to the cache. * @internal * @param mutation - The mutation to add. If it has a `scope`, it is queued in that scope.

(mutation: Mutation<any, any, any, any>)

Source from the content-addressed store, hash-verified

165 * @param mutation - The mutation to add. If it has a `scope`, it is queued in that scope.
166 */
167 add(mutation: Mutation<any, any, any, any>): void {
168 this.#mutations.add(mutation)
169 const scope = scopeFor(mutation)
170 if (typeof scope === 'string') {
171 const scopedMutations = this.#scopes.get(scope)
172 if (scopedMutations) {
173 scopedMutations.push(mutation)
174 } else {
175 this.#scopes.set(scope, [mutation])
176 }
177 }
178 this.notify({ type: 'added', mutation })
179 }
180
181 /**
182 * Removes a mutation from the cache.

Callers 1

buildMethod · 0.95

Calls 3

notifyMethod · 0.95
scopeForFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected