Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/framework/angular/reference/functions/injectQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -116,7 +116,7 @@ export class Posts {
function injectQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(injectQueryFn: () => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
```

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.

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -236,7 +237,7 @@ export class Posts {
function injectQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(injectQueryFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
```

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
Expand Down
41 changes: 23 additions & 18 deletions docs/framework/preact/reference/functions/useQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData,
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
```

- [`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.

Expand All @@ -27,10 +27,11 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary)
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError>;
```

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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -110,7 +112,7 @@ function Posts() {
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
```

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`.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -216,7 +219,7 @@ function Posts() {
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
```

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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.

<a id="result-properties"></a>

Expand Down
41 changes: 23 additions & 18 deletions docs/framework/react/reference/functions/useQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData,
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
```

- [`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.

Expand All @@ -29,10 +29,11 @@ See also: [Parameters](#parameters-summary) · [Returns](#returns-summary)
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError>;
```

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

Expand Down Expand Up @@ -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
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
`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

Expand Down Expand Up @@ -112,7 +114,7 @@ function Posts() {
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
```

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`.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -218,7 +221,7 @@ function Posts() {
function useQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends readonly unknown[] = readonly unknown[]>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
```

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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.

<a id="result-properties"></a>

Expand Down
Loading
Loading