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

Method defaultMutationOptions

packages/query-core/src/queryClient.ts:1147–1160  ·  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

1145 * @returns The defaulted options.
1146 */
1147 defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(
1148 options?: T,
1149 ): T {
1150 if (options?._defaulted) {
1151 return options
1152 }
1153 return {
1154 ...this.#defaultOptions.mutations,
1155 ...(options?.mutationKey &&
1156 this.getMutationDefaults(options.mutationKey)),
1157 ...options,
1158 _defaulted: true,
1159 } as T
1160 }
1161
1162 /**
1163 * 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