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

Method setMutationDefaults

packages/query-core/src/queryClient.ts:930–946  ·  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. * * @see {@link QueryClient#getMutationDefa

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

Source from the content-addressed store, hash-verified

928 * ```
929 */
930 setMutationDefaults<
931 TData = unknown,
932 TError = DefaultError,
933 TVariables = void,
934 TOnMutateResult = unknown,
935 >(
936 mutationKey: MutationKey,
937 options: OmitKeyof<
938 MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,
939 'mutationKey'
940 >,
941 ): void {
942 this.#mutationDefaults.set(hashKey(mutationKey), {
943 mutationKey,
944 defaultOptions: options,
945 })
946 }
947
948 /**
949 * 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