MCPcopy
hub / github.com/TanStack/query / setOptions

Method setOptions

packages/query-core/src/mutationObserver.ts:65–94  ·  view source on GitHub ↗
(
    options: MutationObserverOptions<
      TData,
      TError,
      TVariables,
      TOnMutateResult
    >,
  )

Source from the content-addressed store, hash-verified

63 }
64
65 setOptions(
66 options: MutationObserverOptions<
67 TData,
68 TError,
69 TVariables,
70 TOnMutateResult
71 >,
72 ) {
73 const prevOptions = this.options as
74 | MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>
75 | undefined
76 this.options = this.#client.defaultMutationOptions(options)
77 if (!shallowEqualObjects(this.options, prevOptions)) {
78 this.#client.getMutationCache().notify({
79 type: 'observerOptionsUpdated',
80 mutation: this.#currentMutation,
81 observer: this,
82 })
83 }
84
85 if (
86 prevOptions?.mutationKey &&
87 this.options.mutationKey &&
88 hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)
89 ) {
90 this.reset()
91 } else if (this.#currentMutation?.state.status === 'pending') {
92 this.#currentMutation.setOptions(this.options)
93 }
94 }
95
96 protected onUnsubscribe(): void {
97 if (!this.hasListeners()) {

Callers 4

useMutationFunction · 0.95
createMutationFunction · 0.95
useMutationFunction · 0.95
constructorMethod · 0.95

Calls 6

resetMethod · 0.95
shallowEqualObjectsFunction · 0.90
hashKeyFunction · 0.90
getMutationCacheMethod · 0.80
notifyMethod · 0.45

Tested by

no test coverage detected