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

Method setMutationDefaults

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

* Sets default options for mutations whose mutation key partially matches the given * `mutationKey`. As with QueryClient#setQueryDefaults, the order of registration * matters when several registered defaults match the same mutation key. * @param mutationKey - The mutation key that m

(
    mutationKey: MutationKey,
    options: OmitKeyof<
      MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,
      'mutationKey'
    >,
  )

Source from the content-addressed store, hash-verified

1003 * ```
1004 */
1005 setMutationDefaults<
1006 TData = unknown,
1007 TError = DefaultError,
1008 TVariables = void,
1009 TOnMutateResult = unknown,
1010 >(
1011 mutationKey: MutationKey,
1012 options: OmitKeyof<
1013 MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,
1014 'mutationKey'
1015 >,
1016 ): void {
1017 this.#mutationDefaults.set(hashKey(mutationKey), {
1018 mutationKey,
1019 defaultOptions: options,
1020 })
1021 }
1022
1023 /**
1024 * Returns the default options registered for mutations whose mutation key partially matches

Callers 10

ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
mutation.test.tsxFile · 0.45
hydration.test.tsxFile · 0.45

Calls 1

hashKeyFunction · 0.90

Tested by

no test coverage detected