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

Method defaultMutationOptions

packages/query-core/src/queryClient.ts:1152–1165  ·  view source on GitHub ↗

* The mutation counterpart of QueryClient#defaultQueryOptions. Called by framework * adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then * `queryClient.setMutationDefaults` for the given `mutationKey`, then the caller's options on * top. A no-

(
    options?: T,
  )

Source from the content-addressed store, hash-verified

1150 * @returns The defaulted options.
1151 */
1152 defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(
1153 options?: T,
1154 ): T {
1155 if (options?._defaulted) {
1156 return options
1157 }
1158 return {
1159 ...this.#defaultOptions.mutations,
1160 ...(options?.mutationKey &&
1161 this.getMutationDefaults(options.mutationKey)),
1162 ...options,
1163 _defaulted: true,
1164 } as T
1165 }
1166
1167 /**
1168 * Clears both the query cache and the mutation cache this client is connected to.

Callers 5

defaultOptionsMethod · 0.80
useMutationFunction · 0.80
setOptionsMethod · 0.80
buildMethod · 0.80

Calls 1

getMutationDefaultsMethod · 0.95

Tested by

no test coverage detected