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

Method mutate

packages/query-core/src/mutationObserver.ts:207–222  ·  view source on GitHub ↗

* Builds a new `Mutation` in the `MutationCache` using the observer's * current options, detaches this observer from any previously observed * mutation, attaches it to the new one, and executes it with the given * variables. * * The optional per-call `options` (`onSuccess`/`onError`/`

(
    variables: TVariables,
    options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>,
  )

Source from the content-addressed store, hash-verified

205 * ```
206 */
207 mutate(
208 variables: TVariables,
209 options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>,
210 ): Promise<TData> {
211 this.#mutateOptions = options
212
213 this.#currentMutation?.removeObserver(this)
214
215 this.#currentMutation = this.#client
216 .getMutationCache()
217 .build(this.#client, this.options)
218
219 this.#currentMutation.addObserver(this)
220
221 return this.#currentMutation.execute(variables)
222 }
223
224 #updateResult(): void {
225 const state =

Callers 15

MutationControllerClass · 0.45
mutateFunction · 0.45
useMutationFunction · 0.45
PageFunction · 0.45
ComponentFunction · 0.45
useMutationFunction · 0.45

Calls 5

getMutationCacheMethod · 0.80
executeMethod · 0.80
removeObserverMethod · 0.45
buildMethod · 0.45
addObserverMethod · 0.45

Tested by 8

PageFunction · 0.36
ComponentFunction · 0.36
PageFunction · 0.36
ComponentFunction · 0.36
MutateFunction · 0.36
PageFunction · 0.36
MutatesFunction · 0.36
ComponentFunction · 0.36