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

Method build

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

* Creates a mutation and adds it to the cache. * @internal * @param client - The client the mutation belongs to, used to default its options. * @param options - The mutation options. They are defaulted with * QueryClient#defaultMutationOptions. * @param state - The initial sta

(
    client: QueryClient,
    options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,
    state?: MutationState<TData, TError, TVariables, TOnMutateResult>,
  )

Source from the content-addressed store, hash-verified

142 * @returns The new mutation, already added to the cache.
143 */
144 build<TData, TError, TVariables, TOnMutateResult>(
145 client: QueryClient,
146 options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,
147 state?: MutationState<TData, TError, TVariables, TOnMutateResult>,
148 ): Mutation<TData, TError, TVariables, TOnMutateResult> {
149 const mutation = new Mutation({
150 client,
151 mutationCache: this,
152 mutationId: ++this.#mutationId,
153 options: client.defaultMutationOptions(options),
154 state,
155 })
156
157 this.add(mutation)
158
159 return mutation
160 }
161
162 /**
163 * Adds a mutation to the cache.

Callers

nothing calls this directly

Calls 2

addMethod · 0.95

Tested by

no test coverage detected