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

Method setOptions

packages/query-core/src/query.ts:203–224  ·  view source on GitHub ↗
(
    options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
  )

Source from the content-addressed store, hash-verified

201 }
202
203 setOptions(
204 options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
205 ): void {
206 this.options = { ...this.#defaultOptions, ...options }
207
208 if (options?._type) {
209 this.#queryType = options._type
210 }
211
212 this.updateGcTime(this.options.gcTime)
213
214 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
215 if (this.state && this.state.data === undefined) {
216 const defaultState = getDefaultState(this.options)
217 if (defaultState.data !== undefined) {
218 this.setState(
219 successState(defaultState.data, defaultState.dataUpdatedAt),
220 )
221 this.#initialState = defaultState
222 }
223 }
224 }
225
226 protected optionalRemove() {
227 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