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

Method setOptions

packages/query-core/src/query.ts:282–303  ·  view source on GitHub ↗

@internal

(
    options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
  )

Source from the content-addressed store, hash-verified

280
281 /** @internal */
282 setOptions(
283 options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
284 ): void {
285 this.options = { ...this.#defaultOptions, ...options }
286
287 if (options?._type) {
288 this.#queryType = options._type
289 }
290
291 this.updateGcTime(this.options.gcTime)
292
293 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
294 if (this.state && this.state.data === undefined) {
295 const defaultState = getDefaultState(this.options)
296 if (defaultState.data !== undefined) {
297 this.setState(
298 successState(defaultState.data, defaultState.dataUpdatedAt),
299 )
300 this.#initialState = defaultState
301 }
302 }
303 }
304
305 protected optionalRemove() {
306 if (!this.observers.length && this.state.fetchStatus === 'idle') {

Callers 15

constructorMethod · 0.95
fetchMethod · 0.95
QueryControllerClass · 0.45
applyOptionsMethod · 0.45
applyOptionsMethod · 0.45
refreshOptionsMethod · 0.45
updaterFunction · 0.45
runFunction · 0.45
Devtools.test.tsxFile · 0.45
useBaseQueryFunction · 0.45
useMutationFunction · 0.45
createBaseQueryFunction · 0.45

Calls 3

setStateMethod · 0.95
successStateFunction · 0.85
getDefaultStateFunction · 0.70

Tested by

no test coverage detected