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

Method setOptions

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

Source from the content-addressed store, hash-verified

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