* Replaces the query's options and applies their `gcTime`. If the query has no data yet, it gets * the `initialData` from the new options, if any. * @internal * @param options - The new query options, merged on top of the query's default options.
(
options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
)
| 351 | * @param options - The new query options, merged on top of the query's default options. |
| 352 | */ |
| 353 | setOptions( |
| 354 | options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, |
| 355 | ): void { |
| 356 | this.options = { ...this.#defaultOptions, ...options } |
| 357 | |
| 358 | if (options?._type) { |
| 359 | this.#queryType = options._type |
| 360 | } |
| 361 | |
| 362 | this.updateGcTime(this.options.gcTime) |
| 363 | |
| 364 | // oxlint-disable-next-line typescript/no-unnecessary-condition -- the constructor calls 'setOptions' before it assigns 'state' |
| 365 | if (this.state && this.state.data === undefined) { |
| 366 | const defaultState = getDefaultState(this.options) |
| 367 | if (defaultState.data !== undefined) { |
| 368 | this.setState( |
| 369 | successState(defaultState.data, defaultState.dataUpdatedAt), |
| 370 | ) |
| 371 | this.#initialState = defaultState |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | protected override optionalRemove() { |
| 377 | if (!this.observers.length && this.state.fetchStatus === 'idle') { |
no test coverage detected