diff --git a/docs/framework/angular/reference/functions/injectQuery.md b/docs/framework/angular/reference/functions/injectQuery.md index e26af5742db..044f2091c7c 100644 --- a/docs/framework/angular/reference/functions/injectQuery.md +++ b/docs/framework/angular/reference/functions/injectQuery.md @@ -73,7 +73,7 @@ Additional configuration [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<`TData`, `TError`\> The query result, typed so that `data` is never `undefined` (unless a `select` changes `TData` to -include `undefined`). +include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call. ### See @@ -116,7 +116,7 @@ export class Posts { function injectQuery(injectQueryFn: () => UndefinedInitialDataOptions, options?: InjectQueryOptions): CreateQueryResult; ``` -Defined in: [packages/angular-query-experimental/src/inject-query.ts:158](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L158) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:159](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L159) Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. @@ -158,9 +158,10 @@ Additional configuration [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\> -The query result. `status()` is `'pending'` if there is no cached data to display, `'error'` if -the last fetch attempt failed, or `'success'` if the query has data to display. `isPending`/`isSuccess`/ -`isError` are type-guard methods for convenience. +The query result. `status()` is `'error'` if the query has an error from a fetch that failed +after its retries or if `select` threw, `'success'` if the query has data to display (including +`placeholderData`), and `'pending'` otherwise. `isPending`/`isSuccess`/`isError` are type-guard methods +for convenience. ### See @@ -236,7 +237,7 @@ export class Posts { function injectQuery(injectQueryFn: () => CreateQueryOptions, options?: InjectQueryOptions): CreateQueryResult; ``` -Defined in: [packages/angular-query-experimental/src/inject-query.ts:184](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L184) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:185](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L185) This overload accepts the general [CreateQueryOptions](../interfaces/CreateQueryOptions.md) shape rather than the `initialData`-aware overloads above, so whether `data` is defined can't be inferred from the call site — useful when wrapping diff --git a/docs/framework/preact/reference/functions/useQuery.md b/docs/framework/preact/reference/functions/useQuery.md index b4fd8d83a22..023cc25540f 100644 --- a/docs/framework/preact/reference/functions/useQuery.md +++ b/docs/framework/preact/reference/functions/useQuery.md @@ -13,7 +13,7 @@ function useQuery(options: UseQueryOptions, queryClient?: QueryClient): UseQueryResult; ``` -- [`DefinedInitialDataOptions` → `DefinedUseQueryResult`](#call-signature-1): This overload is selected when `initialData` is known to be defined, so the resulting `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`). +- [`DefinedInitialDataOptions` → `DefinedUseQueryResult`](#call-signature-1): This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call. - [`UndefinedInitialDataOptions` → `UseQueryResult`](#call-signature-2): This overload is selected when `initialData` is omitted, may be `undefined`, or is a function that may return `undefined`, so the resulting `data` can be `undefined`. - [`UseQueryOptions` → `UseQueryResult`](#call-signature-3): Fallback overload for options whose `initialData` presence isn't statically known — for example, an object typed as [UseQueryOptions](../interfaces/UseQueryOptions.md) rather than an object literal. Prefer one of the other overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly. @@ -27,10 +27,11 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary) function useQuery(options: DefinedInitialDataOptions, queryClient?: QueryClient): DefinedUseQueryResult; ``` -Defined in: [packages/preact-query/src/useQuery.ts:49](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L49) +Defined in: [packages/preact-query/src/useQuery.ts:51](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L51) -This overload is selected when `initialData` is known to be defined, so the resulting `data` is never -`undefined` (unless a `select` changes `TData` to include `undefined`). +This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never +`undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` +if `select` throws on its first call. ### Type Parameters @@ -69,9 +70,10 @@ be used. [`DefinedUseQueryResult`](../type-aliases/DefinedUseQueryResult.md)\<`TData`, `TError`\> -The current query result, typed so that `status` is `success` — or `error` if a fetch attempt -fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, -since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. +The current query result, typed so that `status` is `success` or `error` (`status` never +resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is +`error` if the query has an error from a fetch that failed after its retries or if `select` threw, and +`success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. ### See @@ -110,7 +112,7 @@ function Posts() { function useQuery(options: UndefinedInitialDataOptions, queryClient?: QueryClient): UseQueryResult; ``` -Defined in: [packages/preact-query/src/useQuery.ts:116](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L116) +Defined in: [packages/preact-query/src/useQuery.ts:119](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L119) This overload is selected when `initialData` is omitted, may be `undefined`, or is a function that may return `undefined`, so the resulting `data` can be `undefined`. @@ -152,9 +154,10 @@ be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. ### See @@ -216,7 +219,7 @@ function Posts() { function useQuery(options: UseQueryOptions, queryClient?: QueryClient): UseQueryResult; ``` -Defined in: [packages/preact-query/src/useQuery.ts:281](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L281) +Defined in: [packages/preact-query/src/useQuery.ts:285](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L285) Fallback overload for options whose `initialData` presence isn't statically known — for example, an object typed as [UseQueryOptions](../interfaces/UseQueryOptions.md) rather than an object literal. Prefer one of the other overloads @@ -259,9 +262,10 @@ be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. ### See @@ -469,9 +473,10 @@ be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. diff --git a/docs/framework/react/reference/functions/useQuery.md b/docs/framework/react/reference/functions/useQuery.md index d9dac87d9f2..906fb028afe 100644 --- a/docs/framework/react/reference/functions/useQuery.md +++ b/docs/framework/react/reference/functions/useQuery.md @@ -15,7 +15,7 @@ function useQuery(options: UseQueryOptions, queryClient?: QueryClient): UseQueryResult; ``` -- [`DefinedInitialDataOptions` → `DefinedUseQueryResult`](#call-signature-1): This overload is selected when `initialData` is known to be defined, so the resulting `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`). +- [`DefinedInitialDataOptions` → `DefinedUseQueryResult`](#call-signature-1): This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call. - [`UndefinedInitialDataOptions` → `UseQueryResult`](#call-signature-2): This overload is selected when `initialData` is omitted, may be `undefined`, or is a function that may return `undefined`, so the resulting `data` can be `undefined`. - [`UseQueryOptions` → `UseQueryResult`](#call-signature-3): Fallback overload for options whose `initialData` presence isn't statically known — for example, an object typed as [UseQueryOptions](../interfaces/UseQueryOptions.md) rather than an object literal. Prefer one of the other overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly. @@ -29,10 +29,11 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary) function useQuery(options: DefinedInitialDataOptions, queryClient?: QueryClient): DefinedUseQueryResult; ``` -Defined in: [packages/react-query/src/useQuery.ts:49](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L49) +Defined in: [packages/react-query/src/useQuery.ts:51](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L51) -This overload is selected when `initialData` is known to be defined, so the resulting `data` is never -`undefined` (unless a `select` changes `TData` to include `undefined`). +This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never +`undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` +if `select` throws on its first call. ### Type Parameters @@ -71,9 +72,10 @@ be used. [`DefinedUseQueryResult`](../type-aliases/DefinedUseQueryResult.md)\<`TData`, `TError`\> -The current query result, typed so that `status` is `success` — or `error` if a fetch attempt -fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, -since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. +The current query result, typed so that `status` is `success` or `error` (`status` never +resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is +`error` if the query has an error from a fetch that failed after its retries or if `select` threw, and +`success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. ### See @@ -112,7 +114,7 @@ function Posts() { function useQuery(options: UndefinedInitialDataOptions, queryClient?: QueryClient): UseQueryResult; ``` -Defined in: [packages/react-query/src/useQuery.ts:116](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L116) +Defined in: [packages/react-query/src/useQuery.ts:119](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L119) This overload is selected when `initialData` is omitted, may be `undefined`, or is a function that may return `undefined`, so the resulting `data` can be `undefined`. @@ -154,9 +156,10 @@ be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. ### See @@ -218,7 +221,7 @@ function Posts() { function useQuery(options: UseQueryOptions, queryClient?: QueryClient): UseQueryResult; ``` -Defined in: [packages/react-query/src/useQuery.ts:281](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L281) +Defined in: [packages/react-query/src/useQuery.ts:285](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L285) Fallback overload for options whose `initialData` presence isn't statically known — for example, an object typed as [UseQueryOptions](../interfaces/UseQueryOptions.md) rather than an object literal. Prefer one of the other overloads @@ -261,9 +264,10 @@ be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. ### See @@ -471,9 +475,10 @@ be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. diff --git a/docs/framework/solid/reference/functions/useQuery.md b/docs/framework/solid/reference/functions/useQuery.md index 84b66cab679..a6a42b48f60 100644 --- a/docs/framework/solid/reference/functions/useQuery.md +++ b/docs/framework/solid/reference/functions/useQuery.md @@ -27,13 +27,14 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary) function useQuery(options: DefinedInitialDataOptions, queryClient?: () => QueryClient): DefinedUseQueryResult; ``` -Defined in: [packages/solid-query/src/useQuery.ts:57](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L57) +Defined in: [packages/solid-query/src/useQuery.ts:58](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L58) Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. The query runs when the options call for it — `enabled: false` skips the initial fetch. -This overload is selected when `initialData` is known to be defined, so the resulting `data` is never -`undefined` (unless a `select` changes `TData` to include `undefined`). +This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never +`undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` +if `select` throws on its first call. ### Type Parameters @@ -73,10 +74,10 @@ will be used. [`DefinedUseQueryResult`](../type-aliases/DefinedUseQueryResult.md)\<`TData`, `TError`\> -The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a -fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's -type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for -convenience. +The current query result, as a Solid store, typed so that `status` is `success` or `error` +(`status` never resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). +`status` is `error` if the query has an error from a fetch that failed after its retries or if `select` +threw, and `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. ### See @@ -116,7 +117,7 @@ function Posts() { function useQuery(options: UndefinedInitialDataOptions, queryClient?: () => QueryClient): UseQueryResult; ``` -Defined in: [packages/solid-query/src/useQuery.ts:228](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L228) +Defined in: [packages/solid-query/src/useQuery.ts:230](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L230) Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. The query runs when the options call for it — `enabled: false` skips the initial fetch. @@ -159,9 +160,10 @@ will be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result, as a Solid store. `status` is `pending` if there is no cached data to -display, `error` if the last fetch attempt failed, or `success` if the query has data to display. -`isPending`/`isSuccess`/`isError` are derived booleans for convenience. +The current query result, as a Solid store. `status` is `error` if the query has an error from +a fetch that failed after its retries or if `select` threw, `success` if the query has data to display +(including `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived +booleans for convenience. ### See @@ -348,9 +350,10 @@ will be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result, as a Solid store. `status` is `pending` if there is no cached data to -display, `error` if the last fetch attempt failed, or `success` if the query has data to display. -`isPending`/`isSuccess`/`isError` are derived booleans for convenience. +The current query result, as a Solid store. `status` is `error` if the query has an error from +a fetch that failed after its retries or if `select` threw, `success` if the query has data to display +(including `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived +booleans for convenience. diff --git a/docs/framework/solid/reference/variables/createQuery.md b/docs/framework/solid/reference/variables/createQuery.md index 6c50cabff6c..ad979c4a776 100644 --- a/docs/framework/solid/reference/variables/createQuery.md +++ b/docs/framework/solid/reference/variables/createQuery.md @@ -23,8 +23,9 @@ Defined in: [packages/solid-query/src/index.ts:57](https://github.com/TanStack/q Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. The query runs when the options call for it — `enabled: false` skips the initial fetch. -This overload is selected when `initialData` is known to be defined, so the resulting `data` is never -`undefined` (unless a `select` changes `TData` to include `undefined`). +This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never +`undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` +if `select` throws on its first call. ### Type Parameters @@ -64,10 +65,10 @@ will be used. [`DefinedUseQueryResult`](../type-aliases/DefinedUseQueryResult.md)\<`TData`, `TError`\> -The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a -fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's -type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for -convenience. +The current query result, as a Solid store, typed so that `status` is `success` or `error` +(`status` never resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). +`status` is `error` if the query has an error from a fetch that failed after its retries or if `select` +threw, and `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. ### See @@ -146,9 +147,10 @@ will be used. [`UseQueryResult`](../type-aliases/UseQueryResult.md)\<`TData`, `TError`\> -The current query result, as a Solid store. `status` is `pending` if there is no cached data to -display, `error` if the last fetch attempt failed, or `success` if the query has data to display. -`isPending`/`isSuccess`/`isError` are derived booleans for convenience. +The current query result, as a Solid store. `status` is `error` if the query has an error from +a fetch that failed after its retries or if `select` threw, `success` if the query has data to display +(including `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived +booleans for convenience. ### See diff --git a/docs/framework/svelte/reference/functions/createQuery.md b/docs/framework/svelte/reference/functions/createQuery.md index 8e9eaa8e931..b6cc54688dc 100644 --- a/docs/framework/svelte/reference/functions/createQuery.md +++ b/docs/framework/svelte/reference/functions/createQuery.md @@ -27,13 +27,14 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary) function createQuery(options: Accessor>, queryClient?: Accessor): DefinedCreateQueryResult; ``` -Defined in: [packages/svelte-query/src/createQuery.ts:53](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/createQuery.ts#L53) +Defined in: [packages/svelte-query/src/createQuery.ts:55](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/createQuery.ts#L55) Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. The query runs when the options call for it — `enabled: false` skips the initial fetch. -This overload is selected when `initialData` is known to be defined, so the resulting `data` is never -`undefined` (unless a `select` changes `TData` to include `undefined`). +This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never +`undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` +if `select` throws on its first call. ### Type Parameters @@ -73,9 +74,10 @@ be used. [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<`TData`, `TError`\> -The current query result, typed so that `status` is `success` — or `error` if a fetch attempt -fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, -since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. +The current query result, typed so that `status` is `success` or `error` (`status` never +resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is +`error` if the query has an error from a fetch that failed after its retries or if `select` threw, and +`success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. ### See @@ -114,7 +116,7 @@ since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived function createQuery(options: Accessor>, queryClient?: Accessor): CreateQueryResult; ``` -Defined in: [packages/svelte-query/src/createQuery.ts:124](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/createQuery.ts#L124) +Defined in: [packages/svelte-query/src/createQuery.ts:127](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/createQuery.ts#L127) Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. The query runs when the options call for it — `enabled: false` skips the initial fetch. @@ -157,9 +159,10 @@ be used. [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. ### See @@ -222,7 +225,7 @@ The same query, checking `isPending`/`isError` instead of `status` — pick whic function createQuery(options: Accessor>, queryClient?: Accessor): CreateQueryResult; ``` -Defined in: [packages/svelte-query/src/createQuery.ts:249](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/createQuery.ts#L249) +Defined in: [packages/svelte-query/src/createQuery.ts:253](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/createQuery.ts#L253) Fallback overload for options whose `initialData` presence isn't statically known — for example, an object typed as [CreateQueryOptions](../type-aliases/CreateQueryOptions.md) rather than an object literal. Prefer one of the other @@ -266,9 +269,10 @@ be used. [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. ### See @@ -434,9 +438,10 @@ be used. [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived booleans for convenience. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for +convenience. diff --git a/docs/framework/vue/reference/functions/useQuery.md b/docs/framework/vue/reference/functions/useQuery.md index 80fd95b7e53..5beba974a25 100644 --- a/docs/framework/vue/reference/functions/useQuery.md +++ b/docs/framework/vue/reference/functions/useQuery.md @@ -15,7 +15,7 @@ function useQuery(options: MaybeRefOrGetter>, queryClient?: QueryClient): UseQueryReturnType; ``` -- [`DefinedInitialQueryOptions` → `UseQueryDefinedReturnType`](#call-signature-1): This overload is selected when `initialData` is known to be defined, so the resulting `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`). +- [`DefinedInitialQueryOptions` → `UseQueryDefinedReturnType`](#call-signature-1): This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call. - [`UndefinedInitialQueryOptions` → `UseQueryReturnType`](#call-signature-2): `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as a plain value, and stay reactive when passed as a `ref` or a `computed`. - [`MaybeRefOrGetter` → `UseQueryReturnType`](#call-signature-3): Fallback overload for options whose `initialData` presence isn't statically known — for example, a `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly. @@ -29,10 +29,11 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary) function useQuery(options: DefinedInitialQueryOptions, queryClient?: QueryClient): UseQueryDefinedReturnType; ``` -Defined in: [packages/vue-query/src/useQuery.ts:77](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L77) +Defined in: [packages/vue-query/src/useQuery.ts:78](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L78) -This overload is selected when `initialData` is known to be defined, so the resulting `data` is never -`undefined` (unless a `select` changes `TData` to include `undefined`). +This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never +`undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` +if `select` throws on its first call. `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is @@ -78,11 +79,11 @@ will be used. [`UseQueryDefinedReturnType`](../type-aliases/UseQueryDefinedReturnType.md)\<`TData`, `TError`\> -The current query result, typed so that `status` is `success` — or `error` if a fetch attempt -fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, -since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived boolean `ref`s for -convenience. `state` is that result as one readonly reactive object — `state.data`, `state.isPending`, and -the rest are plain values. +The current query result, typed so that `status` is `success` or `error` (`status` never resolves +to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is `error` if +the query has an error from a fetch that failed after its retries or if `select` threw, and `success` +otherwise. `isSuccess`/`isError` are derived boolean `ref`s for convenience. `state` is that result as one +readonly reactive object — `state.data`, `state.isPending`, and the rest are plain values. ### Example @@ -115,7 +116,7 @@ const { data, isError, error } = useQuery({ function useQuery(options: UndefinedInitialQueryOptions, queryClient?: QueryClient): UseQueryReturnType; ``` -Defined in: [packages/vue-query/src/useQuery.ts:239](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L239) +Defined in: [packages/vue-query/src/useQuery.ts:240](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L240) `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is @@ -160,11 +161,11 @@ will be used. [`UseQueryReturnType`](../type-aliases/UseQueryReturnType.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object — -`state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows -`state.data` to `TData`. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived boolean `ref`s for +convenience. `state` is that result as one readonly reactive object — `state.data`, `state.isPending`, and +the rest are plain values, and `state.status === 'success'` narrows `state.data` to `TData`. ### Examples @@ -313,7 +314,7 @@ const { state } = useQuery({ function useQuery(options: MaybeRefOrGetter>, queryClient?: QueryClient): UseQueryReturnType; ``` -Defined in: [packages/vue-query/src/useQuery.ts:317](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L317) +Defined in: [packages/vue-query/src/useQuery.ts:318](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L318) Fallback overload for options whose `initialData` presence isn't statically known — for example, a `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other @@ -364,11 +365,11 @@ will be used. [`UseQueryReturnType`](../type-aliases/UseQueryReturnType.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object — -`state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows -`state.data` to `TData`. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived boolean `ref`s for +convenience. `state` is that result as one readonly reactive object — `state.data`, `state.isPending`, and +the rest are plain values, and `state.status === 'success'` narrows `state.data` to `TData`. ### Examples @@ -442,8 +443,8 @@ will be used. [`UseQueryReturnType`](../type-aliases/UseQueryReturnType.md)\<`TData`, `TError`\> -The current query result. `status` is `pending` if there is no cached data to display, `error` if -the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` -are derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object — -`state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows -`state.data` to `TData`. +The current query result. `status` is `error` if the query has an error from a fetch that failed +after its retries or if `select` threw, `success` if the query has data to display (including +`placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived boolean `ref`s for +convenience. `state` is that result as one readonly reactive object — `state.data`, `state.isPending`, and +the rest are plain values, and `state.status === 'success'` narrows `state.data` to `TData`. diff --git a/packages/angular-query-experimental/src/inject-query.ts b/packages/angular-query-experimental/src/inject-query.ts index a2599a2fe87..ba19463dca6 100644 --- a/packages/angular-query-experimental/src/inject-query.ts +++ b/packages/angular-query-experimental/src/inject-query.ts @@ -39,7 +39,7 @@ export interface InjectQueryOptions { * query. * @param options - Additional configuration * @returns The query result, typed so that `data` is never `undefined` (unless a `select` changes `TData` to - * include `undefined`). + * include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call. * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like * `queryClient.fetchQuery`. @@ -90,9 +90,10 @@ export function injectQuery< * you can pass to `injectQuery`. Similar to `computed` from Angular, this function runs in the reactive * context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query. * @param options - Additional configuration - * @returns The query result. `status()` is `'pending'` if there is no cached data to display, `'error'` if - * the last fetch attempt failed, or `'success'` if the query has data to display. `isPending`/`isSuccess`/ - * `isError` are type-guard methods for convenience. + * @returns The query result. `status()` is `'error'` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `'success'` if the query has data to display (including + * `placeholderData`), and `'pending'` otherwise. `isPending`/`isSuccess`/`isError` are type-guard methods + * for convenience. * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like * `queryClient.fetchQuery`. diff --git a/packages/preact-query/src/useQuery.ts b/packages/preact-query/src/useQuery.ts index 38a8e356f0b..9abc32d441e 100644 --- a/packages/preact-query/src/useQuery.ts +++ b/packages/preact-query/src/useQuery.ts @@ -13,14 +13,16 @@ import type { } from './types' /** - * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never - * `undefined` (unless a `select` changes `TData` to include `undefined`). + * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never + * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` + * if `select` throws on its first call. * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt - * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, - * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. + * @returns The current query result, typed so that `status` is `success` or `error` (`status` never + * resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is + * `error` if the query has an error from a fetch that failed after its retries or if `select` threw, and + * `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx @@ -62,9 +64,10 @@ export function useQuery< * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if - * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` - * are derived booleans for convenience. + * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `success` if the query has data to display (including + * `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for + * convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx @@ -130,9 +133,10 @@ export function useQuery< * @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if - * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` - * are derived booleans for convenience. + * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `success` if the query has data to display (including + * `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for + * convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx diff --git a/packages/react-query/src/useQuery.ts b/packages/react-query/src/useQuery.ts index dfd49331657..b7af6dce603 100644 --- a/packages/react-query/src/useQuery.ts +++ b/packages/react-query/src/useQuery.ts @@ -13,14 +13,16 @@ import type { } from './queryOptions' /** - * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never - * `undefined` (unless a `select` changes `TData` to include `undefined`). + * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never + * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` + * if `select` throws on its first call. * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt - * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, - * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. + * @returns The current query result, typed so that `status` is `success` or `error` (`status` never + * resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is + * `error` if the query has an error from a fetch that failed after its retries or if `select` threw, and + * `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx @@ -62,9 +64,10 @@ export function useQuery< * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if - * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` - * are derived booleans for convenience. + * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `success` if the query has data to display (including + * `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for + * convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx @@ -130,9 +133,10 @@ export function useQuery< * @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if - * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` - * are derived booleans for convenience. + * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `success` if the query has data to display (including + * `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for + * convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx diff --git a/packages/solid-query/src/useQuery.ts b/packages/solid-query/src/useQuery.ts index 8b9d3a53e67..f66ea2a8691 100644 --- a/packages/solid-query/src/useQuery.ts +++ b/packages/solid-query/src/useQuery.ts @@ -18,16 +18,17 @@ import type { * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. * The query runs when the options call for it — `enabled: false` skips the initial fetch. * - * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never - * `undefined` (unless a `select` changes `TData` to include `undefined`). + * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never + * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` + * if `select` throws on its first call. * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can * pass to `useQuery`, with `initialData` known to be defined. * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context * will be used. - * @returns The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a - * fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's - * type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for - * convenience. + * @returns The current query result, as a Solid store, typed so that `status` is `success` or `error` + * (`status` never resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). + * `status` is `error` if the query has an error from a fetch that failed after its retries or if `select` + * threw, and `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx @@ -71,9 +72,10 @@ export function useQuery< * pass to `useQuery`. * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context * will be used. - * @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to - * display, `error` if the last fetch attempt failed, or `success` if the query has data to display. - * `isPending`/`isSuccess`/`isError` are derived booleans for convenience. + * @returns The current query result, as a Solid store. `status` is `error` if the query has an error from + * a fetch that failed after its retries or if `select` threw, `success` if the query has data to display + * (including `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived + * booleans for convenience. * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @example * ```tsx diff --git a/packages/svelte-query/src/createQuery.ts b/packages/svelte-query/src/createQuery.ts index 9c53b49cae6..8df41fb5d7e 100644 --- a/packages/svelte-query/src/createQuery.ts +++ b/packages/svelte-query/src/createQuery.ts @@ -16,15 +16,17 @@ import type { * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. * The query runs when the options call for it — `enabled: false` skips the initial fetch. * - * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never - * `undefined` (unless a `select` changes `TData` to include `undefined`). + * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never + * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` + * if `select` throws on its first call. * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `createQuery`, * with `initialData` known to be defined, wrapped in an {@link Accessor} so options can be reactive. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt - * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, - * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. + * @returns The current query result, typed so that `status` is `success` or `error` (`status` never + * resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is + * `error` if the query has an error from a fetch that failed after its retries or if `select` threw, and + * `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience. * @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`. * @example * ```svelte @@ -69,9 +71,10 @@ export function createQuery< * wrapped in an {@link Accessor} so options can be reactive. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if - * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` - * are derived booleans for convenience. + * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `success` if the query has data to display (including + * `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for + * convenience. * @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`. * @example * ```svelte @@ -141,9 +144,10 @@ export function createQuery< * in an {@link Accessor} so options can be reactive. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if - * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` - * are derived booleans for convenience. + * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed + * after its retries or if `select` threw, `success` if the query has data to display (including + * `placeholderData`), and `pending` otherwise. `isPending`/`isSuccess`/`isError` are derived booleans for + * convenience. * @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`. * @example * `select` derives whatever `data` a component needs from the cached value, without changing what's diff --git a/packages/vue-query/src/useQuery.ts b/packages/vue-query/src/useQuery.ts index 5f40ef1b10e..20dfba5be4c 100644 --- a/packages/vue-query/src/useQuery.ts +++ b/packages/vue-query/src/useQuery.ts @@ -35,8 +35,9 @@ export type UseQueryDefinedReturnType = UseBaseQueryReturnType< > /** - * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never - * `undefined` (unless a `select` changes `TData` to include `undefined`). + * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never + * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined` + * if `select` throws on its first call. * * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is @@ -47,11 +48,11 @@ export type UseQueryDefinedReturnType = UseBaseQueryReturnType< * with `initialData` known to be defined. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin` * will be used. - * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt - * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, - * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived boolean `ref`s for - * convenience. `state` is that result as one readonly reactive object — `state.data`, `state.isPending`, and - * the rest are plain values. + * @returns The current query result, typed so that `status` is `success` or `error` (`status` never resolves + * to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is `error` if + * the query has an error from a fetch that failed after its retries or if `select` threw, and `success` + * otherwise. `isSuccess`/`isError` are derived boolean `ref`s for convenience. `state` is that result as one + * readonly reactive object — `state.data`, `state.isPending`, and the rest are plain values. * @example * ```vue *