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

Method getMutationDefaults

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

* Returns the default options registered for mutations whose mutation key partially matches * the given `mutationKey`, via QueryClient#setMutationDefaults. If multiple registered * defaults match, they are merged together in registration order. * @param mutationKey - The mutation ke

(
    mutationKey: MutationKey,
  )

Source from the content-addressed store, hash-verified

1028 * ```
1029 */
1030 getMutationDefaults(
1031 mutationKey: MutationKey,
1032 ): OmitKeyof<MutationObserverOptions<any, any, any, any>, 'mutationKey'> {
1033 const defaults = [...this.#mutationDefaults.values()]
1034
1035 const result: OmitKeyof<
1036 MutationObserverOptions<any, any, any, any>,
1037 'mutationKey'
1038 > = {}
1039
1040 defaults.forEach((queryDefault) => {
1041 if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
1042 Object.assign(result, queryDefault.defaultOptions)
1043 }
1044 })
1045
1046 return result
1047 }
1048
1049 /**
1050 * Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the

Callers 9

ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45

Calls 1

partialMatchKeyFunction · 0.90

Tested by

no test coverage detected