* @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
(
options: FetchQueryOptions<
TQueryFnData,
TError,
TData,
TQueryKey,
TPageParam
>,
)
| 600 | * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. |
| 601 | */ |
| 602 | fetchQuery< |
| 603 | TQueryFnData, |
| 604 | TError = DefaultError, |
| 605 | TData = TQueryFnData, |
| 606 | TQueryKey extends QueryKey = QueryKey, |
| 607 | TPageParam = never, |
| 608 | >( |
| 609 | options: FetchQueryOptions< |
| 610 | TQueryFnData, |
| 611 | TError, |
| 612 | TData, |
| 613 | TQueryKey, |
| 614 | TPageParam |
| 615 | >, |
| 616 | ): Promise<TData> { |
| 617 | const defaultedOptions = this.defaultQueryOptions(options) |
| 618 | |
| 619 | // https://github.com/tannerlinsley/react-query/issues/652 |
| 620 | if (defaultedOptions.retry === undefined) { |
| 621 | defaultedOptions.retry = false |
| 622 | } |
| 623 | |
| 624 | const query = this.#queryCache.build(this, defaultedOptions) |
| 625 | |
| 626 | return query.isStaleByTime( |
| 627 | resolveQueryValue(defaultedOptions.staleTime, query), |
| 628 | ) |
| 629 | ? query.fetch(defaultedOptions) |
| 630 | : Promise.resolve(query.state.data as TData) |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. |
no test coverage detected