diff --git a/.changeset/angular-stable-release.md b/.changeset/angular-stable-release.md
new file mode 100644
index 00000000000..7577a4d58ad
--- /dev/null
+++ b/.changeset/angular-stable-release.md
@@ -0,0 +1,7 @@
+---
+'@tanstack/angular-query': major
+'@tanstack/angular-query-devtools': major
+'@tanstack/angular-query-persist-client': major
+---
+
+Add the stable Angular Query adapter for Angular 20.1+. It includes SSR support, Resource API interoperability, persistence integration, improved internal subscription and pending tasks management, stable `injectQueries` and consistency improvements in the API.
diff --git a/.changeset/config.json b/.changeset/config.json
index 984e1d89f1c..f5cbfb9fc03 100644
--- a/.changeset/config.json
+++ b/.changeset/config.json
@@ -6,12 +6,15 @@
],
"commit": false,
"access": "public",
- "baseBranch": "main",
+ "baseBranch": "angular-adapter-pre",
"updateInternalDependencies": "patch",
"fixed": [
[
- "@tanstack/angular-query-experimental",
- "@tanstack/angular-query-persist-client",
+ "@tanstack/angular-query",
+ "@tanstack/angular-query-devtools",
+ "@tanstack/angular-query-persist-client"
+ ],
+ [
"@tanstack/eslint-plugin-query",
"@tanstack/preact-query",
"@tanstack/preact-query-devtools",
diff --git a/.changeset/pre.json b/.changeset/pre.json
new file mode 100644
index 00000000000..a63b0811ca7
--- /dev/null
+++ b/.changeset/pre.json
@@ -0,0 +1,35 @@
+{
+ "mode": "pre",
+ "tag": "rc",
+ "initialVersions": {
+ "@tanstack/angular-query": "4.0.0",
+ "@tanstack/angular-query-devtools": "4.0.0",
+ "@tanstack/angular-query-experimental": "5.103.1",
+ "@tanstack/angular-query-persist-client": "4.0.0",
+ "@tanstack/eslint-plugin-query": "5.103.1",
+ "@tanstack/lit-query": "0.2.22",
+ "@tanstack/preact-query": "5.103.1",
+ "@tanstack/preact-query-devtools": "5.103.1",
+ "@tanstack/preact-query-persist-client": "5.103.1",
+ "@tanstack/query-async-storage-persister": "5.103.1",
+ "@tanstack/query-broadcast-client-experimental": "5.103.1",
+ "@tanstack/query-core": "5.103.1",
+ "@tanstack/query-devtools": "5.103.1",
+ "@tanstack/query-persist-client-core": "5.103.1",
+ "@tanstack/query-sync-storage-persister": "5.103.1",
+ "@tanstack/query-test-utils": "0.0.0",
+ "@tanstack/react-query": "5.103.1",
+ "@tanstack/react-query-devtools": "5.103.1",
+ "@tanstack/react-query-next-experimental": "5.103.1",
+ "@tanstack/react-query-persist-client": "5.103.1",
+ "@tanstack/solid-query": "5.103.1",
+ "@tanstack/solid-query-devtools": "5.103.1",
+ "@tanstack/solid-query-persist-client": "5.103.1",
+ "@tanstack/svelte-query": "6.2.1",
+ "@tanstack/svelte-query-devtools": "6.2.1",
+ "@tanstack/svelte-query-persist-client": "6.2.1",
+ "@tanstack/vue-query": "5.103.1",
+ "@tanstack/vue-query-devtools": "6.2.1"
+ },
+ "changesets": []
+}
diff --git a/docs/config.json b/docs/config.json
index 9bbeb14325c..918e29fb4bf 100644
--- a/docs/config.json
+++ b/docs/config.json
@@ -176,20 +176,20 @@
"to": "framework/angular/quick-start"
},
{
- "label": "Angular HttpClient and other data fetching clients",
+ "label": "Devtools",
+ "to": "framework/angular/devtools"
+ },
+ {
+ "label": "Angular HttpClient",
"to": "framework/angular/angular-httpclient-and-other-data-fetching-clients"
},
{
- "label": "Devtools",
- "to": "framework/angular/devtools"
+ "label": "Resource API",
+ "to": "framework/angular/resource-api"
},
{
"label": "TypeScript",
"to": "framework/angular/typescript"
- },
- {
- "label": "Zoneless",
- "to": "framework/angular/zoneless"
}
]
},
@@ -774,6 +774,10 @@
"label": "Default Query Fn",
"to": "framework/angular/guides/default-query-function"
},
+ {
+ "label": "SSR",
+ "to": "framework/angular/guides/ssr"
+ },
{
"label": "Testing",
"to": "framework/angular/guides/testing"
@@ -781,6 +785,18 @@
{
"label": "Does this replace state managers?",
"to": "framework/angular/guides/does-this-replace-client-state"
+ },
+ {
+ "label": "Migrating from Experimental",
+ "to": "framework/angular/guides/migrating-from-experimental"
+ },
+ {
+ "label": "Migrating from ngneat/query",
+ "to": "framework/angular/guides/migrating-from-ngneat-query"
+ },
+ {
+ "label": "Error Handling",
+ "to": "framework/angular/guides/error-handling"
}
]
},
@@ -5048,28 +5064,12 @@
"label": "Functions / partialMatchKey",
"to": "framework/angular/reference/functions/partialMatchKey"
},
- {
- "label": "Functions / provideAngularQuery",
- "to": "framework/angular/reference/functions/provideAngularQuery"
- },
- {
- "label": "Functions / provideIsRestoring",
- "to": "framework/angular/reference/functions/provideIsRestoring"
- },
- {
- "label": "Functions / provideQueryClient",
- "to": "framework/angular/reference/functions/provideQueryClient"
- },
{
"label": "Functions / provideTanStackQuery",
"to": "framework/angular/reference/functions/provideTanStackQuery"
},
{
- "label": "Functions / queryFeature",
- "to": "framework/angular/reference/functions/queryFeature"
- },
- {
- "label": "Functions / queryOptions",
+ "label": "queryOptions",
"to": "framework/angular/reference/functions/queryOptions"
},
{
@@ -5132,10 +5132,6 @@
"label": "Interfaces / CancelOptions",
"to": "framework/angular/reference/interfaces/CancelOptions"
},
- {
- "label": "Interfaces / CreateBaseQueryOptions",
- "to": "framework/angular/reference/interfaces/CreateBaseQueryOptions"
- },
{
"label": "Interfaces / CreateInfiniteQueryOptions",
"to": "framework/angular/reference/interfaces/CreateInfiniteQueryOptions"
diff --git a/docs/framework/angular/angular-httpclient-and-other-data-fetching-clients.md b/docs/framework/angular/angular-httpclient-and-other-data-fetching-clients.md
index 031e9fa8f8b..783a55990e5 100644
--- a/docs/framework/angular/angular-httpclient-and-other-data-fetching-clients.md
+++ b/docs/framework/angular/angular-httpclient-and-other-data-fetching-clients.md
@@ -1,22 +1,16 @@
---
id: Angular-HttpClient-and-other-data-fetching-clients
-title: Angular HttpClient and other data fetching clients
+title: Angular HttpClient
---
-Because TanStack Query's fetching mechanisms are agnostically built on Promises, you can use literally any asynchronous data fetching client, including the browser native `fetch` API, `graphql-request`, and more.
+TanStack Query works with any data fetching client that returns a Promise, including the browser's
+`fetch` API and clients such as `graphql-request`.
## Using Angular's `HttpClient` for data fetching
-`HttpClient` is a powerful and integrated part of Angular, which gives the following benefits:
-
-- Mock responses in unit tests using [provideHttpClientTesting](https://angular.dev/guide/http/testing).
-- [Interceptors](https://angular.dev/guide/http/interceptors) can be used for a wide range of functionality including adding authentication headers, performing logging, etc. While some data fetching libraries have their own interceptor system, `HttpClient` interceptors are integrated with Angular's dependency injection system.
-- `HttpClient` automatically informs [`PendingTasks`](https://angular.dev/api/core/PendingTasks#), which enables Angular to be aware of pending requests. Unit tests and SSR can use the resulting application _stableness_ information to wait for pending requests to finish. This makes unit testing much easier for [Zoneless](https://angular.dev/guide/zoneless) applications.
-- When using SSR, `HttpClient` will [cache requests](https://angular.dev/guide/ssr#caching-data-when-using-HttpClient) performed on the server. This will prevent unneeded requests on the client. `HttpClient` SSR caching works out of the box. TanStack Query has its own hydration functionality which may be more powerful but requires some setup. Which one fits your needs best depends on your use case.
-
-### Using observables in `queryFn`
-
-As TanStack Query is a promise based library, observables from `HttpClient` need to be converted to promises. This can be done with the `lastValueFrom` or `firstValueFrom` functions from `rxjs`.
+Angular's `HttpClient` returns Observables, which query and mutation functions do not consume
+directly. Convert the Observable with RxJS's `firstValueFrom` or `lastValueFrom`. Query functions
+can also return a synchronous value.
```ts
@Component({
@@ -28,21 +22,28 @@ class ExampleComponent {
readonly repoDataQuery = injectQuery(() => ({
queryKey: ['repoData'],
queryFn: () =>
- lastValueFrom(
+ firstValueFrom(
this.http.get('https://api.github.com/repos/tanstack/query'),
),
}))
}
```
-> Since Angular is moving towards RxJS as an optional dependency, it's expected that `HttpClient` will also support promises in the future.
->
-> Support for observables in TanStack Query for Angular is planned.
+For regular `HttpClient` requests, `firstValueFrom` resolves the single response and unsubscribes.
+Use `lastValueFrom` when the Observable emits multiple values and the query should resolve with the
+last one.
+
+Angular [HTTP interceptors](https://angular.dev/guide/http/interceptors) continue to apply to
+requests made inside query and mutation functions.
+
+## SSR
+
+When using `HttpClient` with SSR, prefer Angular Query's built-in query hydration and disable
+Angular's HTTP transfer cache. Otherwise, both systems serialize the same request data.
-## Comparison table
+Add
+[`withNoHttpTransferCache()`](https://angular.dev/api/platform-browser/withNoHttpTransferCache) to
+[`provideClientHydration()`](https://angular.dev/api/platform-browser/provideClientHydration). See
+the [SSR guide](./guides/ssr.md) for the complete setup.
-| Data fetching client | Pros | Cons |
-| --------------------------------------------------- | --------------------------------------------------- | -------------------------------------------------------------------------- |
-| **Angular HttpClient** | Featureful and very well integrated with Angular. | Observables need to be converted to Promises. |
-| **Fetch** | Browser native API, so adds nothing to bundle size. | Barebones API which lacks many features. |
-| **Specialized libraries such as `graphql-request`** | Specialized features for specific use cases. | If it's not an Angular library it won't integrate well with the framework. |
+For cancellation, see [Query Cancellation](./guides/query-cancellation.md).
diff --git a/docs/framework/angular/devtools.md b/docs/framework/angular/devtools.md
index 0103213a350..2af57274fef 100644
--- a/docs/framework/angular/devtools.md
+++ b/docs/framework/angular/devtools.md
@@ -11,79 +11,129 @@ title: Devtools
## Enable devtools
+Add the devtools package (in addition to `@tanstack/angular-query`):
+
+```bash
+npm install @tanstack/angular-query-devtools
+```
+
The devtools help you debug and inspect your queries and mutations. You can enable the devtools by adding `withDevtools` to `provideTanStackQuery`.
-By default, Angular Query Devtools are only included in development mode bundles, so you don't need to worry about excluding them during a production build.
+By default, Angular Query Devtools only load in development.
```ts
-import {
- QueryClient,
- provideTanStackQuery,
-} from '@tanstack/angular-query-experimental'
+import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query'
-import { withDevtools } from '@tanstack/angular-query-experimental/devtools'
+import { withDevtools } from '@tanstack/angular-query-devtools'
export const appConfig: ApplicationConfig = {
- providers: [provideTanStackQuery(new QueryClient(), withDevtools())],
+ providers: [provideTanStackQuery(() => new QueryClient(), withDevtools())],
}
```
## Devtools in production
-Devtools are automatically excluded from production builds. However, it might be desirable to lazy load the devtools in production.
-
-To use `withDevtools` in production builds, import using the `production` sub-path. The function exported from the production subpath is identical to the main one, but won't be excluded from production builds.
+If you need the real implementation in production, import from the `production` entrypoint.
```ts
-import { withDevtools } from '@tanstack/angular-query-experimental/devtools/production'
+import { withDevtools } from '@tanstack/angular-query-devtools/production'
```
-To control when devtools are loaded, you can use the `loadDevtools` option.
+To control when devtools are rendered, use the `loadDevtools` option.
-When not setting the option or setting it to 'auto', the devtools will be loaded automatically only when Angular runs in development mode.
+When omitted or set to `'auto'`, devtools are only rendered in development mode.
```ts
-import { withDevtools } from '@tanstack/angular-query-experimental/devtools'
+import { withDevtools } from '@tanstack/angular-query-devtools'
-provideTanStackQuery(new QueryClient(), withDevtools())
+providers: [provideTanStackQuery(() => new QueryClient(), withDevtools())]
// which is equivalent to
-provideTanStackQuery(
- new QueryClient(),
- withDevtools(() => ({ loadDevtools: 'auto' })),
-)
+providers: [
+ provideTanStackQuery(
+ () => new QueryClient(),
+ withDevtools(() => ({ loadDevtools: 'auto' })),
+ ),
+]
```
-When setting the option to true, the devtools will be loaded in both development and production mode.
+When setting the option to true, the devtools will be rendered in both development and production mode.
This is useful if you want to load devtools based on [Angular environment configurations](https://angular.dev/tools/cli/environments). E.g. you could set this to true when the application is running on your production build staging environment.
```ts
import { environment } from './environments/environment'
// Make sure to use the production sub-path to load devtools in production builds
-import { withDevtools } from '@tanstack/angular-query-experimental/devtools/production'
+import { withDevtools } from '@tanstack/angular-query-devtools/production'
+
+providers: [
+ provideTanStackQuery(
+ () => new QueryClient(),
+ withDevtools(() => ({ loadDevtools: environment.loadDevtools })),
+ ),
+]
+```
+
+When setting the option to false, the devtools will not be rendered.
-provideTanStackQuery(
- new QueryClient(),
- withDevtools(() => ({ loadDevtools: environment.loadDevtools })),
-)
+```ts
+providers: [
+ provideTanStackQuery(
+ () => new QueryClient(),
+ withDevtools(() => ({ loadDevtools: false })),
+ ),
+]
```
-When setting the option to false, the devtools will not be loaded.
+### Webpack file replacements
+
+Some webpack-based Angular builders do not apply package export conditions when
+they bundle application code. Use the explicit `production` and `stub`
+entrypoints with Angular CLI file replacements to keep the devtools dependency
+out of production bundles.
+
+Create an application-level import that can be replaced:
```ts
-provideTanStackQuery(
- new QueryClient(),
- withDevtools(() => ({ loadDevtools: false })),
-)
+// src/app/query-devtools.ts
+export { withDevtools } from '@tanstack/angular-query-devtools/production'
```
-## Derive options through reactivity
+```ts
+// src/app/query-devtools.stub.ts
+export { withDevtools } from '@tanstack/angular-query-devtools/stub'
+```
-Options are passed to `withDevtools` from a callback function to support reactivity through signals. In the following example
-a signal is created from a RxJS observable that emits on a keyboard shortcut. When the derived signal is set to true, the devtools are lazily loaded.
+Import the application-level module from your config:
-The example below always loads devtools in development mode and loads on-demand in production mode when a keyboard shortcut is pressed.
+```ts
+import { withDevtools } from './query-devtools'
+```
+
+Then configure the production build:
+
+```json
+{
+ "configurations": {
+ "production": {
+ "fileReplacements": [
+ {
+ "replace": "src/app/query-devtools.ts",
+ "with": "src/app/query-devtools.stub.ts"
+ }
+ ]
+ }
+ }
+}
+```
+
+The same pattern is available for the programmatic panel:
+`@tanstack/angular-query-devtools/devtools-panel/production` and
+`@tanstack/angular-query-devtools/devtools-panel/stub`.
+
+## Reactive options
+
+Mutable options can be Angular signals. For example, a signal derived from a keyboard shortcut can show devtools on demand:
```ts
import { Injectable, isDevMode } from '@angular/core'
@@ -107,29 +157,23 @@ export class DevtoolsOptionsManager {
}
```
-If you want to use an injectable such as a service in the callback you can use `deps`. The injected value will be passed as parameter to the callback function.
-
-This is similar to `deps` in Angular's [`useFactory`](https://angular.dev/guide/di/dependency-injection-providers#factory-providers-usefactory) provider.
+The callback runs once in an Angular injection context, so it can call
+`inject()`. Return signals as option values to update them reactively:
```ts
// ...
-// 👇 Note we import from the production sub-path to enable devtools lazy loading in production builds
-import { withDevtools } from '@tanstack/angular-query-experimental/devtools/production'
+// 👇 Import from the production sub-path to make devtools available in production builds
+import { inject } from '@angular/core'
+import { withDevtools } from '@tanstack/angular-query-devtools/production'
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(),
provideTanStackQuery(
- new QueryClient(),
- withDevtools(
- (devToolsOptionsManager: DevtoolsOptionsManager) => ({
- loadDevtools: devToolsOptionsManager.loadDevtools(),
- }),
- {
- // `deps` is used to inject and pass `DevtoolsOptionsManager` to the `withDevtools` callback.
- deps: [DevtoolsOptionsManager],
- },
- ),
+ () => new QueryClient(),
+ withDevtools(() => ({
+ loadDevtools: inject(DevtoolsOptionsManager).loadDevtools,
+ })),
),
],
}
@@ -137,11 +181,16 @@ export const appConfig: ApplicationConfig = {
### Options returned from the callback
-Of these options `loadDevtools`, `client`, `position`, `errorTypes`, `buttonPosition`, `initialIsOpen`, and `theme` support reactivity through signals.
+`loadDevtools`, `client`, `position`, `errorTypes`, `buttonPosition`,
+`initialIsOpen`, and `theme` accept either their documented static value or a
+signal containing that value.
+
+`styleNonce`, `shadowDOMTarget`, and `hideDisabledQueries` are construction-time
+options and do not accept signals.
- `loadDevtools?: 'auto' | boolean`
- - Defaults to `auto`: lazily loads devtools when in development mode. Skips loading in production mode.
- - Use this to control if the devtools are loaded.
+ - Omit or `'auto'`: load devtools only in development mode.
+ - Use this to control whether devtools load when using the `/production` import.
- `initialIsOpen?: Boolean`
- Set this to `true` if you want the tools to default to being open
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "relative"`
@@ -164,4 +213,4 @@ Of these options `loadDevtools`, `client`, `position`, `errorTypes`, `buttonPosi
- Set this to true to hide disabled queries from the devtools panel.
- `theme?: "light" | "dark" | "system"`
- Defaults to `system`.
- - Set this to change the theme of the devtools panel.
+ - Sets the theme of the devtools panel.
diff --git a/docs/framework/angular/guides/background-fetching-indicators.md b/docs/framework/angular/guides/background-fetching-indicators.md
index 9e5c5804383..032ffae833b 100644
--- a/docs/framework/angular/guides/background-fetching-indicators.md
+++ b/docs/framework/angular/guides/background-fetching-indicators.md
@@ -6,7 +6,7 @@ replace:
{
'useIsFetching': 'injectIsFetching',
'hook': 'function',
- '@tanstack/react-query': '@tanstack/angular-query-experimental',
+ '@tanstack/react-query': '@tanstack/angular-query',
}
---
@@ -42,7 +42,7 @@ class TodosComponent {
[//]: # 'Example2'
```angular-ts
-import { injectIsFetching } from '@tanstack/angular-query-experimental'
+import { injectIsFetching } from '@tanstack/angular-query'
@Component({
selector: 'global-loading-indicator',
@@ -58,3 +58,14 @@ export class GlobalLoadingIndicatorComponent {
```
[//]: # 'Example2'
+
+## Reactive filters
+
+Pass a factory when filtering activity. It can read signals or required component inputs:
+
+```ts
+readonly isFetching = injectIsFetching(() => ({ queryKey: ['todos', this.userId()] }))
+readonly isMutating = injectIsMutating(() => ({ mutationKey: ['save', this.userId()] }))
+```
+
+The count updates when these dependencies change.
diff --git a/docs/framework/angular/guides/default-query-function.md b/docs/framework/angular/guides/default-query-function.md
index a7ba445b318..9227eed2817 100644
--- a/docs/framework/angular/guides/default-query-function.md
+++ b/docs/framework/angular/guides/default-query-function.md
@@ -16,16 +16,17 @@ const defaultQueryFn: QueryFunction = async ({ queryKey }) => {
}
// provide the default query function to your app with defaultOptions
-const queryClient = new QueryClient({
- defaultOptions: {
- queries: {
- queryFn: defaultQueryFn,
+const createQueryClient = () =>
+ new QueryClient({
+ defaultOptions: {
+ queries: {
+ queryFn: defaultQueryFn,
+ },
},
- },
-})
+ })
bootstrapApplication(MyAppComponent, {
- providers: [provideTanStackQuery(queryClient)],
+ providers: [provideTanStackQuery(createQueryClient)],
})
export class PostsComponent {
diff --git a/docs/framework/angular/guides/dependent-queries.md b/docs/framework/angular/guides/dependent-queries.md
index 38afbd491f7..a1a58286120 100644
--- a/docs/framework/angular/guides/dependent-queries.md
+++ b/docs/framework/angular/guides/dependent-queries.md
@@ -27,7 +27,13 @@ projectsQuery = injectQuery(() => ({
[//]: # 'Example2'
```ts
-// injectQueries is under development for Angular Query
+projectsQueries = injectQueries(() => ({
+ queries:
+ this.userQuery.data()?.projectIds.map((projectId) => ({
+ queryKey: ['project', projectId],
+ queryFn: () => getProjectById(projectId),
+ })) ?? [],
+}))
```
[//]: # 'Example2'
diff --git a/docs/framework/angular/guides/disabling-queries.md b/docs/framework/angular/guides/disabling-queries.md
index b52266505aa..07bacf2d914 100644
--- a/docs/framework/angular/guides/disabling-queries.md
+++ b/docs/framework/angular/guides/disabling-queries.md
@@ -70,7 +70,7 @@ export class TodosComponent {
[//]: # 'Example3'
```angular-ts
-import { skipToken, injectQuery } from '@tanstack/angular-query-experimental'
+import { skipToken, injectQuery } from '@tanstack/angular-query'
@Component({
selector: 'todos',
diff --git a/docs/framework/angular/guides/does-this-replace-client-state.md b/docs/framework/angular/guides/does-this-replace-client-state.md
index 3872115c940..c1118ff4b28 100644
--- a/docs/framework/angular/guides/does-this-replace-client-state.md
+++ b/docs/framework/angular/guides/does-this-replace-client-state.md
@@ -4,8 +4,10 @@ title: Does TanStack Query replace global state managers?
ref: docs/framework/react/guides/does-this-replace-client-state.md
replace:
{
- 'useQuery': 'injectQuery',
- 'useMutation': 'injectMutation',
+ 'Does TanStack Query replace Redux, MobX or other global state managers\?': 'Does TanStack Query replace global state managers?',
+ 'Redux, MobX, Zustand, etc.': 'NgRx Store, Signal Store, etc.',
+ '`useQuery`': '`injectQuery`',
+ '`useMutation`': '`injectMutation`',
'hook': 'function',
}
---
diff --git a/docs/framework/angular/guides/error-handling.md b/docs/framework/angular/guides/error-handling.md
new file mode 100644
index 00000000000..4efdfcf87ef
--- /dev/null
+++ b/docs/framework/angular/guides/error-handling.md
@@ -0,0 +1,57 @@
+---
+id: error-handling
+title: Error Handling
+---
+
+Query and mutation errors are exposed through their result signals. The adapter does not report
+failed requests to a global error handler automatically.
+
+To report cache failures to Angular's `ErrorHandler`, configure the cache callbacks when creating
+the client. Capture the handler in the provider factory, where `inject()` is available:
+
+```ts
+import { ErrorHandler, inject } from '@angular/core'
+import {
+ MutationCache,
+ QueryCache,
+ QueryClient,
+ provideTanStackQuery,
+} from '@tanstack/angular-query'
+
+export const queryProviders = provideTanStackQuery(() => {
+ const errors = inject(ErrorHandler)
+
+ return new QueryClient({
+ queryCache: new QueryCache({
+ onError: (error, query) => {
+ if (query.meta?.reportToErrorHandler !== false) {
+ errors.handleError(error)
+ }
+ },
+ }),
+ mutationCache: new MutationCache({
+ onError: (error, _variables, _context, mutation) => {
+ if (mutation.meta?.reportToErrorHandler !== false) {
+ errors.handleError(error)
+ }
+ },
+ }),
+ })
+})
+```
+
+This example reports failures by default. Set `meta: { reportToErrorHandler: false }` on a query or
+mutation which your application handles locally. Compose these callbacks with any cache callbacks
+you already use.
+
+A query cache callback reports a failed cache operation once, even when several components observe
+the query. Observer-only `select` errors and exceptions in options or `combine` computations are
+not cache failures and are not reported by this recipe.
+
+`mutateAsync()` rejects and can be caught with `try`/`catch`. `mutate()` returns void; use mutation
+callbacks or result signals for its error state. `refetch({ throwOnError: true })` opts into promise
+rejection for that call.
+
+The [Resource view](../resource-api.md) throws from `value()` when its mapped status is `error`.
+Check `hasValue()` before reading it. An uncaught error while Angular renders a template can still
+reach Angular's error handler. This integration does not provide a component error boundary.
diff --git a/docs/framework/angular/guides/important-defaults.md b/docs/framework/angular/guides/important-defaults.md
index 886792038b1..95a6b1df98a 100644
--- a/docs/framework/angular/guides/important-defaults.md
+++ b/docs/framework/angular/guides/important-defaults.md
@@ -6,6 +6,7 @@ replace:
{
'React': 'Angular',
'react-query': 'angular-query',
+ '@tanstack/angular-query': '@tanstack/angular-query',
'useQuery': 'injectQuery',
'useInfiniteQuery': 'injectInfiniteQuery',
'useMemo and useCallback': 'setting signal values',
diff --git a/docs/framework/angular/guides/infinite-queries.md b/docs/framework/angular/guides/infinite-queries.md
index f606cf8c6ba..202c4361377 100644
--- a/docs/framework/angular/guides/infinite-queries.md
+++ b/docs/framework/angular/guides/infinite-queries.md
@@ -10,7 +10,7 @@ replace:
```angular-ts
import { Component, computed, inject } from '@angular/core'
-import { injectInfiniteQuery } from '@tanstack/angular-query-experimental'
+import { injectInfiniteQuery } from '@tanstack/angular-query'
import { lastValueFrom } from 'rxjs'
import { ProjectsService } from './projects-service'
diff --git a/docs/framework/angular/guides/invalidations-from-mutations.md b/docs/framework/angular/guides/invalidations-from-mutations.md
index e69c4e5be7c..dc92e619311 100644
--- a/docs/framework/angular/guides/invalidations-from-mutations.md
+++ b/docs/framework/angular/guides/invalidations-from-mutations.md
@@ -17,10 +17,7 @@ postTodoMutation = injectMutation(() => ({
[//]: # 'Example2'
```ts
-import {
- injectMutation,
- QueryClient,
-} from '@tanstack/angular-query-experimental'
+import { injectMutation, QueryClient } from '@tanstack/angular-query'
export class TodosComponent {
readonly queryClient = inject(QueryClient)
diff --git a/docs/framework/angular/guides/migrating-from-experimental.md b/docs/framework/angular/guides/migrating-from-experimental.md
new file mode 100644
index 00000000000..b541fe0309f
--- /dev/null
+++ b/docs/framework/angular/guides/migrating-from-experimental.md
@@ -0,0 +1,267 @@
+---
+id: migrating-from-experimental
+title: Migrating from Angular Query Experimental
+---
+
+The stable package keeps the callback-based query, mutation, and signal result APIs from the
+experimental adapter. Most application queries therefore only need an import change. The following
+sections cover the breaking configuration and entrypoint changes.
+
+## Replace the experimental package
+
+```bash
+npm uninstall @tanstack/angular-query-experimental
+npm install @tanstack/angular-query
+```
+
+Angular 20.1 or newer is required by the stable package.
+
+```ts
+import { injectQuery } from '@tanstack/angular-query-experimental' // [!code --]
+import { injectQuery } from '@tanstack/angular-query' // [!code ++]
+```
+
+## Provide a client factory
+
+`provideTanStackQuery` no longer accepts a pre-created `QueryClient`. Pass a factory instead.
+
+```ts
+provideTanStackQuery(new QueryClient()) // [!code --]
+provideTanStackQuery(() => new QueryClient()) // [!code ++]
+```
+
+`provideTanStackQuery` now returns one `EnvironmentProviders` value rather than an array. Use it in
+an environment injector, such as `ApplicationConfig.providers`, the `providers` passed to
+`bootstrapApplication`, route-level `Route.providers`, or `createEnvironmentInjector`. It is not
+supported in `@Component.providers` or `@Directive.providers`. Add the result directly; do not
+spread it.
+
+```ts
+providers: [...provideTanStackQuery(() => new QueryClient())] // [!code --]
+providers: [provideTanStackQuery(() => new QueryClient())] // [!code ++]
+```
+
+## Remove deprecated provider and injection helpers
+
+`provideAngularQuery` and `injectQueryClient` have been removed.
+
+```ts
+provideAngularQuery(new QueryClient()) // [!code --]
+provideTanStackQuery(() => new QueryClient()) // [!code ++]
+```
+
+```ts
+const queryClient = injectQueryClient() // [!code --]
+const queryClient = inject(QueryClient) // [!code ++]
+```
+
+## Install the standalone devtools package
+
+Devtools no longer ship as entrypoints of the core Angular package.
+
+```bash
+npm install @tanstack/angular-query-devtools
+```
+
+```ts
+import { withDevtools } from '@tanstack/angular-query-experimental/devtools' // [!code --]
+import { withDevtools } from '@tanstack/angular-query-devtools' // [!code ++]
+```
+
+The production and panel entrypoints move in the same way:
+
+```ts
+import { withDevtools } from '@tanstack/angular-query-experimental/devtools/production' // [!code --]
+import { withDevtools } from '@tanstack/angular-query-devtools/production' // [!code ++]
+```
+
+The devtools options callback now runs in an injection context. Remove the `deps` option and call
+`inject()` inside the callback instead.
+
+```ts
+const optionsFromManager = (manager: DevtoolsOptionsManager) => ({
+ loadDevtools: manager.loadDevtools,
+})
+
+withDevtools(optionsFromManager, { deps: [DevtoolsOptionsManager] }) // [!code --]
+withDevtools(() => optionsFromManager(inject(DevtoolsOptionsManager))) // [!code ++]
+```
+
+See the [Devtools guide](../devtools.md) for setup, production entrypoints, and configuration
+options.
+
+## Use the stable `injectQueries` export
+
+`injectQueries` is now exported from the main package. The helper must be called from an Angular
+injection context.
+
+```ts
+import {
+ injectQueries, // [!code --]
+} from '@tanstack/angular-query-experimental/inject-queries-experimental' // [!code --]
+import { injectQueries } from '@tanstack/angular-query' // [!code ++]
+
+const getQueries = () => ({ queries })
+const results = injectQueries(getQueries, injector) // [!code --]
+const results = runInInjectionContext(injector, () => injectQueries(getQueries)) // [!code ++]
+```
+
+The `queries` callback is reactive, tuple inference is preserved, and `combine` can derive a single
+result:
+
+```ts
+readonly summary = injectQueries(() => ({
+ queries: [todosOptions(), usersOptions()],
+ combine: ([todos, users]) => ({
+ pending: todos.isPending || users.isPending,
+ todoCount: todos.data?.length ?? 0,
+ userCount: users.data?.length ?? 0,
+ }),
+}))
+```
+
+## Review SSR hydration
+
+`provideTanStackQuery` now dehydrates the server cache into Angular `TransferState` and hydrates it
+in the browser by default. In most SSR applications, no additional setup is necessary.
+
+If your application already performs manual dehydration and hydration, either remove the manual
+implementation or disable the built-in behavior to avoid hydrating the same client twice:
+
+```ts
+provideTanStackQuery(() => new QueryClient(), withNoQueryHydration())
+```
+
+Give each client a unique key when multiple clients use automatic hydration:
+
+```ts
+provideTanStackQuery(
+ () => new QueryClient(),
+ withHydrationKey('admin-query-cache'),
+)
+```
+
+See the [SSR guide](./ssr.md) for request-scoped client setup and the interaction with Angular
+`HttpClient` transfer caching.
+
+## Update tests that wait for stability
+
+Observed queries, parallel queries, and mutations started through the adapter register with Angular's `PendingTasks`. As a result, `ApplicationRef.whenStable()` and `fixture.whenStable()` wait until
+that work settles.
+
+This can change existing tests that expected `whenStable()` to resolve while a request was still in
+progress. Make sure mocked requests and mutations resolve or reject before awaiting stability. When
+using fake timers, advance the timers and queued microtasks before awaiting `whenStable()`. Disabled
+queries do not start fetching automatically; a manual refetch still registers pending work.
+
+See [Testing](./testing.md) for query, mutation, `HttpClientTestingController`, and fake-timer
+examples.
+
+## New behavior that needs no migration
+
+The stable package also includes the following compatible improvements:
+
+- Query results can be converted into an Angular Resource with `toResource`. See the
+ [Resource API](../resource-api.md).
+- `injectQueries` is supported from the main package with reactive options and field-level signals.
+- Result field signals are evaluated lazily, so options can safely read required input signals without
+ being evaluated during class construction.
+- Persistence options may be supplied as a browser-only factory, making references such as
+ `localStorage` safe in SSR applications.
+
+## Error handling
+
+Observer options no longer include `throwOnError`. Errors are exposed through the result's
+`error`, `status`, and related signals, without an automatic global report. Cached query data
+remains readable when a background refetch fails.
+
+```ts
+injectQuery(() => ({
+ queryKey: ['todos'],
+ queryFn: fetchTodos,
+ throwOnError: true,
+})) // [!code --]
+injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })) // [!code ++]
+```
+
+Remove observer `throwOnError` from query, infinite-query, and mutation options, including your
+Angular-specific client defaults. The shared core client still accepts this option for other
+framework adapters, but Angular does not use it for reporting.
+
+`mutateAsync()` still rejects on failure, and `mutate()` still returns void. Imperative options
+such as `query.refetch({ throwOnError: true })` retain their promise-rejection behavior.
+To report cache failures to Angular, use the [ErrorHandler guide](./error-handling.md).
+`toResource(query).value()` throws when the Resource is in its error state; guard the read with
+`hasValue()` or inspect `error()` first.
+
+## Use one client provider
+
+```ts
+provideQueryClient(() => new QueryClient()) // [!code --]
+provideTanStackQuery(() => new QueryClient()) // [!code ++]
+```
+
+`provideQueryClient` has been removed. Use `provideTanStackQuery`, which handles mounting,
+unmounting, and default hydration. Replacing it with a bare Angular `useFactory` provider would
+omit that setup.
+
+## Make activity filters reactive
+
+```ts
+injectIsFetching({ queryKey: ['todos'] }) // [!code --]
+injectIsFetching(() => ({ queryKey: ['todos', userId()] })) // [!code ++]
+
+injectIsMutating({ mutationKey: ['save'] }) // [!code --]
+injectIsMutating(() => ({ mutationKey: ['save'] })) // [!code ++]
+```
+
+Calls without filters remain unchanged. Filter factories can read required inputs and signals;
+changing a filter updates the count without waiting for a cache event.
+
+## Imperative methods
+
+Methods such as `refetch()` and `fetchNextPage()` use the current options even when called
+immediately after changing an options signal.
+
+Read the current `injectQueries()` result when calling a method after adding, removing, or
+reordering queries.
+
+`injectMutationState` selections and `injectQueries` combined results are no longer deeply
+compared by the adapter. A newly allocated selected object or combined result can trigger consumers
+even when its contents match the previous value. Prefer returning existing values when possible.
+
+## Stability and notifications
+
+Signal updates no longer enter `NgZone` or wait for adapter microtasks. Angular's change-detection
+scheduler handles rendering. Keep reading reactive values as signals; callbacks do not gain an
+injection context or guaranteed zone membership.
+
+Each mutation invocation blocks stability until its promise settles, including awaited lifecycle
+callbacks. A later invocation completing, or calling `reset()`, does not release an earlier mutation's
+work. Destroying the owning component or injector releases its pending tasks. Queries that are
+paused offline continue to block stability until resumed, cancelled, or unobserved.
+
+## Persistence configuration
+
+Pass a factory to `withPersistQueryClient`:
+
+```ts
+withPersistQueryClient(() => ({
+ persistOptions: { persister },
+}))
+```
+
+The factory runs once per injector, in an injection context, only in the browser.
+Create persisters that access `localStorage` inside this factory.
+
+## QueryClient factories
+
+`provideTanStackQuery` accepts a factory. If another provider already owns the client,
+resolve it inside that factory:
+
+```ts
+provideTanStackQuery(() => inject(MY_QUERY_CLIENT))
+```
+
+Replace direct token arguments with this form. Persistence manages its restoration
+state automatically through `withPersistQueryClient`.
diff --git a/docs/framework/angular/guides/migrating-from-ngneat-query.md b/docs/framework/angular/guides/migrating-from-ngneat-query.md
new file mode 100644
index 00000000000..491d0c2a1ec
--- /dev/null
+++ b/docs/framework/angular/guides/migrating-from-ngneat-query.md
@@ -0,0 +1,246 @@
+---
+id: migrating-from-ngneat-query
+title: Migrating from ngneat/query
+---
+
+Angular Query requires Angular 20.1 or newer.
+
+This guide uses `@ngneat/query` in its examples.
+
+## Replace the packages
+
+Remove whichever legacy package name your application uses, along with its devtools package. The
+stable adapter includes `@tanstack/query-core` as a dependency, so remove a direct installation
+unless your application imports it independently.
+
+```bash
+npm uninstall @ngneat/query @ngneat/query-devtools @tanstack/query-core
+npm install @tanstack/angular-query @tanstack/angular-query-devtools
+```
+
+## Configure the `QueryClient`
+
+Replace `provideQueryClientOptions` with a `QueryClient` factory passed to
+`provideTanStackQuery`. The factory runs in an Angular injection context, so it can call `inject()`
+when building caches or default options.
+
+```ts
+import { QueryCache } from '@ngneat/query' // [!code --]
+import { provideQueryClientOptions } from '@ngneat/query' // [!code --]
+import { QueryCache, QueryClient } from '@tanstack/angular-query' // [!code ++]
+import { provideTanStackQuery } from '@tanstack/angular-query' // [!code ++]
+
+const queryClientConfig = {
+ queryCache: new QueryCache({ onError: handleError }),
+}
+
+providers: [
+ provideQueryClientOptions(queryClientConfig), // [!code --]
+ provideTanStackQuery(() => new QueryClient(queryClientConfig)), // [!code ++]
+]
+```
+
+## Migrate queries
+
+The legacy `injectQuery()` call returned a function that accepted query options. The stable API
+accepts a reactive options callback and returns the query result directly.
+
+```ts
+private readonly useQuery = injectQuery() // [!code --]
+
+readonly todos = this.useQuery({ // [!code --]
+ queryKey: ['todos'], // [!code --]
+ queryFn: fetchTodos, // [!code --]
+}) // [!code --]
+readonly todos = injectQuery(() => ({ // [!code ++]
+ queryKey: ['todos'], // [!code ++]
+ queryFn: fetchTodos, // [!code ++]
+})) // [!code ++]
+```
+
+Read signals inside the callback to update options reactively. This replaces calling
+`updateOptions` yourself.
+
+```ts
+readonly filter = signal('')
+private readonly useQuery = injectQuery() // [!code --]
+readonly todos = this.useQuery({ // [!code --]
+ queryKey: ['todos', this.filter()], // [!code --]
+ queryFn: () => fetchTodos(this.filter()), // [!code --]
+}) // [!code --]
+readonly todos = injectQuery(() => ({ // [!code ++]
+ queryKey: ['todos', this.filter()], // [!code ++]
+ queryFn: () => fetchTodos(this.filter()), // [!code ++]
+})) // [!code ++]
+```
+
+When a helper must be called from a callback that is not already in an injection context, use
+Angular's `runInInjectionContext` at the call site:
+
+```ts
+runInInjectionContext(injector, () => injectQuery(() => queryOptions))
+```
+
+## Migrate infinite queries and mutations
+
+`injectInfiniteQuery` and `injectMutation` use the same callback pattern:
+
+```ts
+private readonly useInfiniteQuery = injectInfiniteQuery() // [!code --]
+readonly posts = this.useInfiniteQuery({ // [!code --]
+ queryKey: ['posts'], // [!code --]
+ queryFn: ({ pageParam }) => fetchPosts(pageParam), // [!code --]
+ initialPageParam: 0, // [!code --]
+ getNextPageParam: (lastPage) => lastPage.nextId, // [!code --]
+}) // [!code --]
+readonly posts = injectInfiniteQuery(() => ({ // [!code ++]
+ queryKey: ['posts'], // [!code ++]
+ queryFn: ({ pageParam }) => fetchPosts(pageParam), // [!code ++]
+ initialPageParam: 0, // [!code ++]
+ getNextPageParam: (lastPage) => lastPage.nextId, // [!code ++]
+})) // [!code ++]
+```
+
+```ts
+private readonly useMutation = injectMutation() // [!code --]
+readonly addTodo = this.useMutation({ // [!code --]
+ mutationFn: addTodo, // [!code --]
+}) // [!code --]
+readonly addTodo = injectMutation(() => ({ // [!code ++]
+ mutationFn: addTodo, // [!code ++]
+})) // [!code ++]
+```
+
+Imperative methods remain direct methods, for example `addTodo.mutate(value)`,
+`addTodo.reset()`, `posts.fetchNextPage()`, and `todos.refetch()`.
+
+## Migrate query and mutation results
+
+The legacy adapter exposed one signal and one Observable containing the entire observer result.
+The stable adapter exposes each result field as a signal and keeps imperative methods as functions.
+
+```ts
+todos.result().isPending // [!code --]
+todos.result().data // [!code --]
+todos.result().error // [!code --]
+todos.isPending() // [!code ++]
+todos.data() // [!code ++]
+todos.error() // [!code ++]
+```
+
+Templates use the field signals in the same way:
+
+```angular-html
+@if (todos.result().isPending) {
+@if (todos.isPending()) {
+ Loading...
+} @else if (todos.isError()) {
+ {{ todos.error()?.message }}
+} @else {
+ @for (todo of todos.data(); track todo.id) {
+ {{ todo.title }}
+ }
+}
+```
+
+There is no direct replacement for `result$`. Convert the field signal you need with Angular's
+`toObservable`, or compose several fields with `computed` first.
+
+```ts
+readonly todosResult$ = this.todos.result$ // [!code --]
+readonly todosState = computed(() => ({ // [!code ++]
+ data: this.todos.data(), // [!code ++]
+ error: this.todos.error(), // [!code ++]
+ status: this.todos.status(), // [!code ++]
+})) // [!code ++]
+readonly todosResult$ = toObservable(this.todosState) // [!code ++]
+```
+
+Mutation state follows the same rule:
+
+```ts
+addTodo.result().isPending // [!code --]
+addTodo.result().data // [!code --]
+addTodo.isPending() // [!code ++]
+addTodo.data() // [!code ++]
+```
+
+## Convert Observable query functions
+
+The legacy adapter accepted an RxJS `Observable` from `queryFn` and `mutationFn`. The stable
+adapter follows TanStack Query's Promise-based contract, so convert an Observable with
+`firstValueFrom` or `lastValueFrom`.
+
+```ts
+queryFn: () => this.http.get('/api/todos') // [!code --]
+queryFn: () => lastValueFrom(this.http.get('/api/todos')) // [!code ++]
+```
+
+```ts
+const createTodo = (todo: Todo) => this.http.post('/api/todos', todo)
+
+mutationFn: createTodo // [!code --]
+mutationFn: (todo) => lastValueFrom(createTodo(todo)) // [!code ++]
+```
+
+See [Angular HttpClient](../angular-httpclient-and-other-data-fetching-clients.md)
+for a complete example. If an Observable does not complete, prefer `firstValueFrom` or make it
+complete before converting it.
+
+## Migrate background indicators
+
+`injectIsFetching` and `injectIsMutating` now accept a reactive filters callback and return a
+`Signal`.
+
+```ts
+private readonly useIsFetching = injectIsFetching() // [!code --]
+readonly fetchingTodos = // [!code --]
+ this.useIsFetching({ queryKey: ['todos'] }).toSignal() // [!code --]
+readonly fetchingTodos = injectIsFetching(() => ({ queryKey: ['todos'] })) // [!code ++]
+```
+
+```ts
+private readonly useIsMutating = injectIsMutating() // [!code --]
+readonly mutatingTodos = // [!code --]
+ this.useIsMutating({ mutationKey: ['todos'] }).toSignal() // [!code --]
+readonly mutatingTodos = injectIsMutating(() => ({ mutationKey: ['todos'] })) // [!code ++]
+```
+
+Use `toObservable(this.fetchingTodos)` if a consumer still needs an Observable.
+
+## Inject the `QueryClient`
+
+Use Angular dependency injection directly instead of `injectQueryClient`:
+
+```ts
+import { injectQueryClient } from '@ngneat/query' // [!code --]
+import { inject } from '@angular/core' // [!code ++]
+import { QueryClient } from '@tanstack/angular-query' // [!code ++]
+
+private readonly queryClient = injectQueryClient() // [!code --]
+private readonly queryClient = inject(QueryClient) // [!code ++]
+```
+
+## Migrate devtools
+
+Replace the legacy devtools provider with the `withDevtools` feature from the standalone Angular
+Query devtools package.
+
+```ts
+import { provideQueryClientOptions } from '@ngneat/query' // [!code --]
+import { provideQueryDevTools } from '@ngneat/query-devtools' // [!code --]
+import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query' // [!code ++]
+import { withDevtools } from '@tanstack/angular-query-devtools' // [!code ++]
+
+const devtools = withDevtools(() => ({ initialIsOpen: true }))
+
+providers: [
+ provideQueryClientOptions({}), // [!code --]
+ provideQueryDevTools({ initialIsOpen: true }), // [!code --]
+ provideTanStackQuery(() => new QueryClient(), devtools), // [!code ++]
+]
+```
+
+See the [Devtools guide](../devtools.md) for production entrypoints and reactive options.
+
+See [Error handling](./error-handling.md) for optional Angular `ErrorHandler` integration.
diff --git a/docs/framework/angular/guides/migrating-to-angular-query.md b/docs/framework/angular/guides/migrating-to-angular-query.md
new file mode 100644
index 00000000000..393d15ea7cc
--- /dev/null
+++ b/docs/framework/angular/guides/migrating-to-angular-query.md
@@ -0,0 +1,11 @@
+---
+id: migrating-to-angular-query
+title: Migrating to Angular Query
+---
+
+Choose the guide for your current adapter:
+
+- [Migrating from Angular Query Experimental](./migrating-from-experimental.md)
+- [Migrating from ngneat/query or openng/query](./migrating-from-ngneat-query.md)
+
+Both target Angular 20.1 or newer.
diff --git a/docs/framework/angular/guides/mutations.md b/docs/framework/angular/guides/mutations.md
index b40933c55ba..18f3e53b4bc 100644
--- a/docs/framework/angular/guides/mutations.md
+++ b/docs/framework/angular/guides/mutations.md
@@ -272,3 +272,5 @@ queryClient.resumePausedMutations()
[//]: # 'Example11'
[//]: # 'Materials'
[//]: # 'Materials'
+
+See [Error handling](./error-handling.md) to connect cache failures to Angular’s `ErrorHandler`.
diff --git a/docs/framework/angular/guides/parallel-queries.md b/docs/framework/angular/guides/parallel-queries.md
index 8e2e2348fc5..d6071e9d3b3 100644
--- a/docs/framework/angular/guides/parallel-queries.md
+++ b/docs/framework/angular/guides/parallel-queries.md
@@ -17,6 +17,9 @@ replace:
[//]: # 'Example'
```ts
+@Component({
+ // ...
+})
export class AppComponent {
// The following queries will execute in parallel
readonly usersQuery = injectQuery(() => ({
@@ -45,12 +48,14 @@ TanStack Query provides `injectQueries`, which you can use to dynamically execut
[//]: # 'Example2'
```ts
+@Component({
+ // ...
+})
export class AppComponent {
users = signal>([])
- // Please note injectQueries is under development and this code does not work yet
- readonly userQueries = injectQueries(() => ({
- queries: users().map((user) => {
+ userQueries = injectQueries(() => ({
+ queries: this.users().map((user) => {
return {
queryKey: ['user', user.id],
queryFn: () => fetchUserById(user.id),
diff --git a/docs/framework/angular/guides/queries.md b/docs/framework/angular/guides/queries.md
index 051d332bf8a..1bf5816d206 100644
--- a/docs/framework/angular/guides/queries.md
+++ b/docs/framework/angular/guides/queries.md
@@ -6,6 +6,7 @@ replace:
{
'React': 'Angular',
'react-query': 'angular-query',
+ '@tanstack/angular-query': '@tanstack/angular-query',
'promise': 'promise or observable',
'custom hooks': 'services',
'the `useQuery` hook': '`injectQuery`',
@@ -17,7 +18,7 @@ replace:
[//]: # 'Example'
```ts
-import { injectQuery } from '@tanstack/angular-query-experimental'
+import { injectQuery } from '@tanstack/angular-query'
export class TodosComponent {
readonly todosQuery = injectQuery(() => ({
@@ -101,4 +102,11 @@ class TodosComponent {}
[//]: # 'Example4'
[//]: # 'Materials'
+
+Angular Query can convert each query result into a Resource-compatible view with `toResource`. See
+the [Resource API](../resource-api.md) when an Angular API expects a
+[Resource](https://angular.dev/api/core/Resource).
+
[//]: # 'Materials'
+
+See [Error handling](./error-handling.md) to connect cache failures to Angular’s `ErrorHandler`.
diff --git a/docs/framework/angular/guides/query-cancellation.md b/docs/framework/angular/guides/query-cancellation.md
index 6d107f2fffc..86de25536c3 100644
--- a/docs/framework/angular/guides/query-cancellation.md
+++ b/docs/framework/angular/guides/query-cancellation.md
@@ -15,7 +15,7 @@ However, if you consume the `AbortSignal`, the Promise will be cancelled (e.g. a
```ts
import { HttpClient } from '@angular/common/http'
-import { injectQuery } from '@tanstack/angular-query-experimental'
+import { injectQuery } from '@tanstack/angular-query'
postQuery = injectQuery(() => ({
enabled: this.postId() > 0,
diff --git a/docs/framework/angular/guides/query-invalidation.md b/docs/framework/angular/guides/query-invalidation.md
index 36956557dcf..eb287dd0070 100644
--- a/docs/framework/angular/guides/query-invalidation.md
+++ b/docs/framework/angular/guides/query-invalidation.md
@@ -8,7 +8,7 @@ replace: { 'useQuery': 'injectQuery', 'hooks': 'functions' }
[//]: # 'Example2'
```ts
-import { injectQuery, QueryClient } from '@tanstack/angular-query-experimental'
+import { injectQuery, QueryClient } from '@tanstack/angular-query'
class QueryInvalidationExample {
readonly queryClient = inject(QueryClient)
diff --git a/docs/framework/angular/guides/query-options.md b/docs/framework/angular/guides/query-options.md
index 4ce9f836d59..19ed50384e8 100644
--- a/docs/framework/angular/guides/query-options.md
+++ b/docs/framework/angular/guides/query-options.md
@@ -7,7 +7,7 @@ ref: docs/framework/react/guides/query-options.md
[//]: # 'Example1'
```ts
-import { queryOptions, noop } from '@tanstack/angular-query-experimental'
+import { noop, queryOptions } from '@tanstack/angular-query'
@Injectable({
providedIn: 'root',
@@ -38,7 +38,7 @@ queries = inject(QueriesService)
postQuery = injectQuery(() => this.queries.post(this.postId()))
-queryClient.query(this.queries.post(23)).catch(noop)
+void queryClient.query(this.queries.post(23)).catch(noop)
queryClient.setQueryData(this.queries.post(42).queryKey, newPost)
```
diff --git a/docs/framework/angular/guides/query-retries.md b/docs/framework/angular/guides/query-retries.md
index a7b0b1841ca..e19c8f85a37 100644
--- a/docs/framework/angular/guides/query-retries.md
+++ b/docs/framework/angular/guides/query-retries.md
@@ -15,7 +15,7 @@ replace:
[//]: # 'Example'
```ts
-import { injectQuery } from '@tanstack/angular-query-experimental'
+import { injectQuery } from '@tanstack/angular-query'
// Make a specific query retry a certain number of times
const todoQuery = injectQuery(() => ({
@@ -33,19 +33,20 @@ const todoQuery = injectQuery(() => ({
import {
QueryCache,
QueryClient,
- provideTanStackQuery,
-} from '@tanstack/angular-query-experimental'
+ QueryClientProvider,
+} from '@tanstack/angular-query'
-const queryClient = new QueryClient({
- defaultOptions: {
- queries: {
- retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
+const createQueryClient = () =>
+ new QueryClient({
+ defaultOptions: {
+ queries: {
+ retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
+ },
},
- },
-})
+ })
bootstrapApplication(AppComponent, {
- providers: [provideTanStackQuery(queryClient)],
+ providers: [provideTanStackQuery(createQueryClient)],
})
```
diff --git a/docs/framework/angular/guides/ssr.md b/docs/framework/angular/guides/ssr.md
new file mode 100644
index 00000000000..2b6b727796f
--- /dev/null
+++ b/docs/framework/angular/guides/ssr.md
@@ -0,0 +1,101 @@
+---
+id: ssr
+title: SSR
+---
+
+For [Angular SSR](https://angular.dev/guide/ssr), [`provideTanStackQuery`](../reference/functions/provideTanStackQuery.md) serializes the `QueryClient` cache into Angular's `TransferState` and restores it when the browser application starts.
+
+See the [Angular SSR example](https://github.com/TanStack/query/tree/main/examples/angular/ssr). The
+[SSR persistence example](https://github.com/TanStack/query/tree/main/examples/angular/ssr-persist)
+builds on the same setup with browser persistence.
+
+## Query client factory
+
+```ts
+import { isPlatformBrowser } from '@angular/common'
+import { inject, PLATFORM_ID } from '@angular/core'
+import { QueryClient } from '@tanstack/angular-query'
+
+export function createQueryClient() {
+ const isBrowser = isPlatformBrowser(inject(PLATFORM_ID))
+
+ return new QueryClient({
+ defaultOptions: {
+ queries: {
+ // Retry failed queries in the browser, but not on the server.
+ retry: isBrowser ? 3 : 0,
+ },
+ },
+ })
+}
+```
+
+## Browser config
+
+Use the factory with `provideTanStackQuery` in your application config. Angular's HTTP transfer
+cache is enabled by default with
+[`provideClientHydration`](https://angular.dev/api/platform-browser/provideClientHydration). Add
+[`withNoHttpTransferCache`](https://angular.dev/api/platform-browser/withNoHttpTransferCache) so
+query results are not serialized once by each cache.
+
+```ts
+import type { ApplicationConfig } from '@angular/core'
+import { provideHttpClient } from '@angular/common/http'
+import {
+ provideClientHydration,
+ withEventReplay,
+ withNoHttpTransferCache,
+} from '@angular/platform-browser'
+import { provideTanStackQuery } from '@tanstack/angular-query'
+import { withDevtools } from '@tanstack/angular-query-devtools'
+import { createQueryClient } from './query-client'
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideHttpClient(),
+ provideClientHydration(withEventReplay(), withNoHttpTransferCache()),
+ provideTanStackQuery(createQueryClient, withDevtools()),
+ ],
+}
+```
+
+## Server config
+
+Merge the application config with `provideServerRendering` in the server config.
+
+```ts
+import { mergeApplicationConfig } from '@angular/core'
+import { provideServerRendering, withRoutes } from '@angular/ssr'
+import { appConfig } from './app.config'
+import { serverRoutes } from './app.routes.server'
+
+export const serverConfig = mergeApplicationConfig(appConfig, {
+ providers: [provideServerRendering(withRoutes(serverRoutes))],
+})
+```
+
+## Multiple query clients
+
+Built-in hydration uses a default transfer key. For a second `QueryClient` in a child injector, pass a distinct key with `withHydrationKey` so each client's serialized cache stays separate.
+
+```ts
+providers: [
+ provideTanStackQuery(
+ createSecondaryQueryClient,
+ withHydrationKey('my-secondary-query-cache'),
+ ),
+]
+```
+
+## Disabling built-in hydration
+
+If you need to opt out of TanStack Query's built-in `TransferState` integration for a specific injector, add `withNoQueryHydration()`.
+
+```ts
+providers: [provideTanStackQuery(createQueryClient, withNoQueryHydration())]
+```
+
+## See also
+
+- [Angular HttpClient and data fetching](../angular-httpclient-and-other-data-fetching-clients.md)
+- [Devtools](../devtools.md)
diff --git a/docs/framework/angular/guides/testing.md b/docs/framework/angular/guides/testing.md
index 7648d7f6b32..2bf32bfd2b1 100644
--- a/docs/framework/angular/guides/testing.md
+++ b/docs/framework/angular/guides/testing.md
@@ -9,11 +9,11 @@ TanStack Query's `inject*` functions integrate with [`PendingTasks`](https://ang
This means tests and SSR can wait until mutations and queries resolve. In unit tests you can use `ApplicationRef.whenStable()` or `fixture.whenStable()` to await query completion. This works for both Zone.js and Zoneless setups.
-> This integration requires Angular 19 or later. Earlier versions of Angular do not support `PendingTasks`.
+> This adapter requires Angular 20.1 or later. It uses `PendingTasks` to keep application stability open while observed work is pending.
## TestBed setup
-Create a fresh `QueryClient` for every spec and provide it with `provideTanStackQuery` or `provideQueryClient`. This keeps caches isolated and lets you change default options per test:
+Create a fresh `QueryClient` for every spec and return it from the provider factory. Keeping a reference makes it easy to inspect or clear the cache:
```ts
const queryClient = new QueryClient({
@@ -25,11 +25,11 @@ const queryClient = new QueryClient({
})
TestBed.configureTestingModule({
- providers: [provideTanStackQuery(queryClient)],
+ providers: [provideTanStackQuery(() => queryClient)],
})
```
-> If your applications actual TanStack Query config is used in unit tests, make sure `withDevtools` is not accidentally included in test providers. This can cause slow tests. It is best to keep test and production configs separate.
+> If your application's TanStack Query config is used in unit tests, make sure `withDevtools` is not accidentally included in test providers. This can cause slow tests. It is best to keep test and production configs separate.
If you share helpers, remember to call `queryClient.clear()` (or build a new instance) in `afterEach` so data from one test never bleeds into another.
@@ -46,7 +46,7 @@ const query = TestBed.runInInjectionContext(() =>
})),
)
-TestBed.tick() // Trigger effect
+TestBed.tick() // Synchronize the test application
// Application is stable when queries are idle
await appRef.whenStable()
@@ -69,6 +69,7 @@ For components, bootstrap them through `TestBed.createComponent`, then await `fi
```ts
const fixture = TestBed.createComponent(ExampleComponent)
+fixture.autoDetectChanges()
await fixture.whenStable()
expect(fixture.componentInstance.query.data()).toEqual({ value: 42 })
@@ -80,12 +81,17 @@ Retries slow failing tests because the default backoff runs three times. Set `re
## HttpClient & network stubs
-Angular's `HttpClientTestingModule` plays nicely with PendingTasks. Register it alongside the Query provider and flush responses through `HttpTestingController`:
+Angular's `provideHttpClientTesting` plays nicely with PendingTasks. Register it after
+`provideHttpClient`, alongside the Query provider, and flush responses through
+`HttpTestingController`:
```ts
TestBed.configureTestingModule({
- imports: [HttpClientTestingModule],
- providers: [provideTanStackQuery(queryClient)],
+ providers: [
+ provideHttpClient(),
+ provideHttpClientTesting(),
+ provideTanStackQuery(() => queryClient),
+ ],
})
const httpCtrl = TestBed.inject(HttpTestingController)
@@ -96,6 +102,7 @@ const query = TestBed.runInInjectionContext(() =>
})),
)
+TestBed.tick() // Synchronize the test application so the request starts
const fixturePromise = TestBed.inject(ApplicationRef).whenStable()
httpCtrl.expectOne('/api/todos').flush([{ id: 1 }])
await fixturePromise
@@ -104,6 +111,17 @@ expect(query.data()).toEqual([{ id: 1 }])
httpCtrl.verify()
```
+Test observable results after normal Angular initialization and updates. For components, render
+with `fixture.detectChanges()` and await `fixture.whenStable()` when the operation should finish.
+For injection-context-only tests, synchronize the test application as shown above. When using
+HTTP mocks or fake timers, flush the request or advance time before awaiting stability.
+
+Avoid asserting an exact subscription order or a stale intermediate value during initialization.
+Those are implementation details. To test pending mutation or fetching state, hold the operation
+open with a controlled promise and assert after rendering; do not await stability until you
+resolve that promise. To test completed state, resolve the operation and await stability before
+asserting the result.
+
## Infinite queries & pagination
Use the same pattern for infinite queries: call `fetchNextPage()`, advance timers if you are faking time, then await stability and assert on `data().pages`.
@@ -112,19 +130,20 @@ Use the same pattern for infinite queries: call `fetchNextPage()`, advance timer
const infinite = TestBed.runInInjectionContext(() =>
injectInfiniteQuery(() => ({
queryKey: ['pages'],
- queryFn: ({ pageParam = 1 }) => fetchPage(pageParam),
+ initialPageParam: 1,
+ queryFn: ({ pageParam }) => fetchPage(pageParam),
getNextPageParam: (last, all) => all.length + 1,
})),
)
+TestBed.tick()
await appRef.whenStable()
-expect(infinite.data().pages).toHaveLength(1)
+expect(infinite.data()?.pages).toHaveLength(1)
await infinite.fetchNextPage()
-await vi.advanceTimersByTimeAsync(0)
await appRef.whenStable()
-expect(infinite.data().pages).toHaveLength(2)
+expect(infinite.data()?.pages).toHaveLength(2)
```
## Mutations and optimistic updates
@@ -138,7 +157,7 @@ const mutation = TestBed.runInInjectionContext(() =>
mutation.mutate('test')
-// Trigger effect
+// Synchronize the test application
TestBed.tick()
await appRef.whenStable()
@@ -147,11 +166,15 @@ expect(mutation.isSuccess()).toBe(true)
expect(mutation.data()).toBe('TEST')
```
+`whenStable()` waits for every mutation invocation, including awaited lifecycle callbacks.
+Resolve or reject all outstanding mocked mutations before awaiting stability; calling `reset()`
+does not finish a request. Queries paused offline also keep stability open until resumed or cancelled.
+
## Quick checklist
- Fresh `QueryClient` per test (and clear it afterwards)
- Disable or control retries to avoid timeouts
- Advance timers + microtasks before `whenStable()` when using fake timers
-- Use `HttpClientTestingModule` or your preferred mock to assert network calls
+- Use `provideHttpClientTesting` or your preferred mock to assert network calls
- Await `whenStable()` after every `refetch`, `fetchNextPage`, or mutation
- Prefer `TestBed.runInInjectionContext` for service tests and `fixture.whenStable()` for component tests
diff --git a/docs/framework/angular/guides/window-focus-refetching.md b/docs/framework/angular/guides/window-focus-refetching.md
index 14490ba07ca..36e446238df 100644
--- a/docs/framework/angular/guides/window-focus-refetching.md
+++ b/docs/framework/angular/guides/window-focus-refetching.md
@@ -2,7 +2,7 @@
id: window-focus-refetching
title: Window Focus Refetching
ref: docs/framework/react/guides/window-focus-refetching.md
-replace: { '@tanstack/react-query': '@tanstack/angular-query-experimental' }
+replace: { '@tanstack/react-query': '@tanstack/angular-query' }
---
[//]: # 'Example'
@@ -11,13 +11,14 @@ replace: { '@tanstack/react-query': '@tanstack/angular-query-experimental' }
export const appConfig: ApplicationConfig = {
providers: [
provideTanStackQuery(
- new QueryClient({
- defaultOptions: {
- queries: {
- refetchOnWindowFocus: false, // default: true
+ () =>
+ new QueryClient({
+ defaultOptions: {
+ queries: {
+ refetchOnWindowFocus: false, // default: true
+ },
},
- },
- }),
+ }),
),
],
}
diff --git a/docs/framework/angular/installation.md b/docs/framework/angular/installation.md
index dffc092e7cd..5cfae0bd3bd 100644
--- a/docs/framework/angular/installation.md
+++ b/docs/framework/angular/installation.md
@@ -3,32 +3,45 @@ id: installation
title: Installation
---
-> IMPORTANT: This library is currently in an experimental stage. This means that breaking changes will happen in minor AND patch releases. Upgrade carefully. If you use this in production while in experimental stage, please lock your version to a patch-level version to avoid unexpected breaking changes.
+_Angular Query is compatible with Angular v20.1 and higher._
-### NPM
+### Angular CLI
-_Angular Query is compatible with Angular v16 and higher_
+```bash
+ng add @tanstack/angular-query
+```
+
+This installs the package and devtools, then configures an SSR-safe `QueryClient` factory with
+`withDevtools()`.
+
+### Package managers
```bash
-npm i @tanstack/angular-query-experimental
+npm i @tanstack/angular-query
```
or
```bash
-pnpm add @tanstack/angular-query-experimental
+pnpm add @tanstack/angular-query
```
or
```bash
-yarn add @tanstack/angular-query-experimental
+yarn add @tanstack/angular-query
```
or
```bash
-bun add @tanstack/angular-query-experimental
+bun add @tanstack/angular-query
+```
+
+If you want Angular Query devtools, install the standalone devtools package as well:
+
+```bash
+npm i @tanstack/angular-query-devtools
```
-> Wanna give it a spin before you download? Try out the [simple](./examples/simple) or [basic](./examples/basic) examples!
+> Want to try it first? See the [simple](./examples/simple) or [basic](./examples/basic) example.
diff --git a/docs/framework/angular/overview.md b/docs/framework/angular/overview.md
index 31dd1131ccb..83dd7497cf5 100644
--- a/docs/framework/angular/overview.md
+++ b/docs/framework/angular/overview.md
@@ -3,17 +3,13 @@ id: overview
title: Overview
---
-> IMPORTANT: This library is currently in an experimental stage. This means that breaking changes will happen in minor AND patch releases. Upgrade carefully. If you use this in production while in experimental stage, please lock your version to a patch-level version to avoid unexpected breaking changes.
+The `@tanstack/angular-query` package offers a 1st-class API for using TanStack Query via Angular.
-The `@tanstack/angular-query-experimental` package offers a 1st-class API for using TanStack Query via Angular.
-
-## Feedback welcome!
-
-We are in the process of getting to a stable API for TanStack Query on Angular. If you have any feedback, please contact us at the [TanStack Discord](https://tlinz.com/discord) server or [visit this discussion](https://github.com/TanStack/query/discussions/6293) on Github.
+If you have any feedback, please contact us at the [TanStack Discord](https://tlinz.com/discord) server or [visit this discussion](https://github.com/TanStack/query/discussions/6293) on Github.
## Supported Angular Versions
-TanStack Query is compatible with Angular v16 and higher.
+TanStack Query is compatible with Angular v20.1 and higher.
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes **fetching, caching, synchronizing and updating server state** in your web applications a breeze.
@@ -63,8 +59,7 @@ In the example below, you can see TanStack Query in its most basic and simple fo
```angular-ts
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
import { HttpClient } from '@angular/common/http'
-import { CommonModule } from '@angular/common'
-import { injectQuery } from '@tanstack/angular-query-experimental'
+import { injectQuery } from '@tanstack/angular-query'
import { lastValueFrom } from 'rxjs'
@Component({
@@ -73,11 +68,10 @@ import { lastValueFrom } from 'rxjs'
template: `
@if (repoDataQuery.isPending()) {
Loading...
- }
- @if (repoDataQuery.error()) {
- An error has occurred: {{ repoDataQuery.error().message }}
- }
- @if (repoDataQuery.data(); as data) {
+ } @else if (query.isError()) {
+ An error has occurred: {{ query.error().message }}
+ } @else if (query.isSuccess()) {
+ @let data = query.data();
{{ data.name }}
{{ data.description }}
👀 {{ data.subscribers_count }}
diff --git a/docs/framework/angular/quick-start.md b/docs/framework/angular/quick-start.md
index cfe29d87b58..c7358a767af 100644
--- a/docs/framework/angular/quick-start.md
+++ b/docs/framework/angular/quick-start.md
@@ -3,42 +3,25 @@ id: quick-start
title: Quick Start
---
-> IMPORTANT: This library is currently in an experimental stage. This means that breaking changes will happen in minor AND patch releases. Upgrade carefully. If you use this in production while in experimental stage, please lock your version to a patch-level version to avoid unexpected breaking changes.
-
[//]: # 'Example'
If you're looking for a fully functioning example, please have a look at our [basic codesandbox example](./examples/basic)
-### Provide the client to your App
+### Configure the QueryClient
-```ts
-import { provideHttpClient } from '@angular/common/http'
-import {
- provideTanStackQuery,
- QueryClient,
-} from '@tanstack/angular-query-experimental'
-
-bootstrapApplication(AppComponent, {
- providers: [provideHttpClient(), provideTanStackQuery(new QueryClient())],
-})
-```
-
-or in a NgModule-based app
+Pass a factory to `provideTanStackQuery`. Angular runs it once per injector and in an injection context, so it can use `inject()`.
```ts
import { provideHttpClient } from '@angular/common/http'
-import {
- provideTanStackQuery,
- QueryClient,
-} from '@tanstack/angular-query-experimental'
+import { bootstrapApplication } from '@angular/platform-browser'
+import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
-@NgModule({
- declarations: [AppComponent],
- imports: [BrowserModule],
- providers: [provideTanStackQuery(new QueryClient())],
- bootstrap: [AppComponent],
+bootstrapApplication(AppComponent, {
+ providers: [
+ provideHttpClient(),
+ provideTanStackQuery(() => new QueryClient()),
+ ],
})
-export class AppModule {}
```
### Component with query and mutation
@@ -52,7 +35,7 @@ import {
injectMutation,
injectQuery,
QueryClient,
-} from '@tanstack/angular-query-experimental'
+} from '@tanstack/angular-query'
@Component({
template: `
diff --git a/docs/framework/angular/reference/classes/CancelledError.md b/docs/framework/angular/reference/classes/CancelledError.md
index 5bd8c049574..4010dfce61c 100644
--- a/docs/framework/angular/reference/classes/CancelledError.md
+++ b/docs/framework/angular/reference/classes/CancelledError.md
@@ -3,7 +3,7 @@ id: CancelledError
title: CancelledError
---
-Defined in: [packages/query-core/src/retryer.ts:81](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L81)
+Defined in: packages/query-core/dist-ts/src/retryer.d.ts:47
The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via
`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch
@@ -36,7 +36,7 @@ try {
new CancelledError(options?: CancelOptions): CancelledError;
```
-Defined in: [packages/query-core/src/retryer.ts:84](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L84)
+Defined in: packages/query-core/dist-ts/src/retryer.d.ts:50
#### Parameters
@@ -110,7 +110,7 @@ Error.name
optional revert: boolean;
```
-Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L82)
+Defined in: packages/query-core/dist-ts/src/retryer.d.ts:48
***
@@ -120,7 +120,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/
optional silent: boolean;
```
-Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L83)
+Defined in: packages/query-core/dist-ts/src/retryer.d.ts:49
***
diff --git a/docs/framework/angular/reference/classes/InfiniteQueryObserver.md b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md
index 5453760e839..5c90f3f9d73 100644
--- a/docs/framework/angular/reference/classes/InfiniteQueryObserver.md
+++ b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md
@@ -3,7 +3,7 @@ id: InfiniteQueryObserver
title: InfiniteQueryObserver
---
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:26
An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch
between infinite queries. It augments the base `QueryObserverResult` with
@@ -58,7 +58,7 @@ const unsubscribe = observer.subscribe((result) => console.log(result))
new InfiniteQueryObserver(client: QueryClient, options: InfiniteQueryObserverOptions): InfiniteQueryObserver;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:30
#### Parameters
@@ -86,7 +86,7 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github
protected fetch: ReplaceReturnType<(fetchOptions: ObserverFetchOptions) => Promise>, Promise>>;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:29
#### Overrides
@@ -102,7 +102,7 @@ QueryObserver.fetch
getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:28
Returns the most recently computed `QueryObserverResult` for the
observed query. This is a point-in-time read; to be notified of updates
@@ -130,7 +130,7 @@ QueryObserver.getCurrentResult
protected listeners: Set>;
```
-Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L7)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:2
#### Inherited from
@@ -144,7 +144,7 @@ Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanSt
options: QueryObserverOptions, TQueryKey>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:31
#### Inherited from
@@ -158,7 +158,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan
subscribe: (listener: InfiniteQueryObserverListener) => () => void;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:27
Registers a listener to be called on every update this object notifies about. Returns a function
that removes the listener again — call it to stop listening. The base class never drops a listener
@@ -206,7 +206,7 @@ QueryObserver.subscribe
protected bindMethods(): void;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:31
#### Returns
@@ -224,7 +224,7 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github
protected createResult(query: Query, TQueryKey>, options: InfiniteQueryObserverOptions): InfiniteQueryObserverResult;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:84
#### Parameters
@@ -252,7 +252,7 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://githu
destroy(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:53
Stops observing the current query: clears all listeners, cancels the
stale and refetch-interval timers, and removes this observer from the
@@ -274,7 +274,7 @@ query it was observing.
fetchNextPage(options?: FetchNextPageOptions): Promise>;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:64
Fetches the next page of the infinite query and returns a promise that
resolves with the resulting `InfiniteQueryObserverResult`. The page
@@ -314,7 +314,7 @@ if (hasNextPage) {
fetchOptimistic(options: QueryObserverOptions, TQueryKey>): Promise>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:134
Fetches a query defined by the given options without affecting this
observer's own tracked query or result, and returns a promise that
@@ -354,7 +354,7 @@ console.log(result.data)
fetchPreviousPage(options?: FetchPreviousPageOptions): Promise>;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:83
Fetches the previous page of the infinite query and returns a promise
that resolves with the resulting `InfiniteQueryObserverResult`. The page
@@ -394,7 +394,7 @@ if (hasPreviousPage) {
getCurrentQuery(): Query, TQueryKey>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:106
Returns the `Query` instance this observer is currently observing.
@@ -414,7 +414,7 @@ Returns the `Query` instance this observer is currently observing.
getOptimisticResult(options: DefaultedInfiniteQueryObserverOptions): InfiniteQueryObserverResult;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:45
The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the
options as an infinite query before delegating to it. Called by framework adapters (e.g.
@@ -443,9 +443,7 @@ synchronously.
hasListeners(): boolean;
```
-Defined in: [packages/query-core/src/subscribable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L41)
-
-Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:5
#### Returns
@@ -463,7 +461,7 @@ Returns `true` while at least one listener is registered, `false` once they have
protected onSubscribe(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:34
#### Returns
@@ -481,7 +479,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/Ta
protected onUnsubscribe(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:35
#### Returns
@@ -496,19 +494,19 @@ Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/Ta
### refetch()
```ts
-refetch(__namedParameters: RefetchOptions): Promise>;
+refetch(__namedParameters?: RefetchOptions): Promise>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:117
Refetches the observed query and returns a promise that resolves with
the resulting `QueryObserverResult`.
#### Parameters
-##### \_\_namedParameters
+##### \_\_namedParameters?
-[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}`
+[`RefetchOptions`](../interfaces/RefetchOptions.md)
#### Returns
@@ -533,7 +531,7 @@ console.log(result.data)
setOptions(options: InfiniteQueryObserverOptions): void;
```
-Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108)
+Defined in: packages/query-core/dist-ts/src/infiniteQueryObserver.d.ts:38
Updates the observer's options. Behaves the same as
`QueryObserver.setOptions`, additionally marking the options as
@@ -562,7 +560,7 @@ implementation.
shouldFetchOnReconnect(): boolean;
```
-Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:41
Returns whether the observed query is currently stale and configured
(via the `refetchOnReconnect` option) to refetch when the network
@@ -584,7 +582,7 @@ reconnects.
shouldFetchOnWindowFocus(): boolean;
```
-Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:47
Returns whether the observed query is currently stale and configured
(via the `refetchOnWindowFocus` option) to refetch when the window
@@ -604,8 +602,8 @@ regains focus.
```ts
trackProp(key:
- | "error"
| "data"
+ | "error"
| "isError"
| "isPending"
| "isLoading"
@@ -631,7 +629,7 @@ trackProp(key:
| "fetchStatus"): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:102
Records that the given `QueryObserverResult` property was read, so a subsequent update only
notifies this observer if a tracked property actually changed. Normally called indirectly via
@@ -642,7 +640,7 @@ access themselves (e.g. through their own reactivity system) instead of via the
##### key
-`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"`
+`"data"` | `"error"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"`
#### Returns
@@ -658,8 +656,8 @@ access themselves (e.g. through their own reactivity system) instead of via the
```ts
trackResult(result: QueryObserverResult, onPropTracked?: (key:
- | "error"
| "data"
+ | "error"
| "isError"
| "isPending"
| "isLoading"
@@ -685,7 +683,7 @@ trackResult(result: QueryObserverResult, onPropTracked?: (key:
| "fetchStatus") => void): QueryObserverResult;
```
-Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:95
Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework
@@ -701,8 +699,8 @@ properties you actually read" behavior.
##### onPropTracked?
(`key`:
- \| `"error"`
\| `"data"`
+ \| `"error"`
\| `"isError"`
\| `"isPending"`
\| `"isLoading"`
@@ -743,7 +741,7 @@ properties you actually read" behavior.
updateResult(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:142
Recomputes and stores the current result from the current query/options, notifying listeners
if it changed. Framework adapters call this right after subscribing to make sure no query
diff --git a/docs/framework/angular/reference/classes/Mutation.md b/docs/framework/angular/reference/classes/Mutation.md
index 49975b76a75..19209829381 100644
--- a/docs/framework/angular/reference/classes/Mutation.md
+++ b/docs/framework/angular/reference/classes/Mutation.md
@@ -3,7 +3,7 @@ id: Mutation
title: Mutation
---
-Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:101
Represents a single mutation attempt. A `Mutation` holds the mutation's
options, state (data/error/status), and the `MutationObserver`s currently
@@ -52,7 +52,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] })
new Mutation(config: MutationConfig): Mutation;
```
-Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:106
#### Parameters
@@ -78,7 +78,7 @@ Removable.constructor
gcTime: number;
```
-Defined in: [packages/query-core/src/removable.ts:11](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L11)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:3
#### Inherited from
@@ -94,7 +94,7 @@ Removable.gcTime
readonly mutationId: number;
```
-Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:105
***
@@ -104,7 +104,7 @@ Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStac
options: MutationOptions;
```
-Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:104
***
@@ -114,7 +114,7 @@ Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStac
state: MutationState;
```
-Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:103
## Accessors
@@ -126,7 +126,7 @@ Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStac
get meta(): Record | undefined;
```
-Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:112
The `meta` object passed in the mutation's options, if any.
@@ -142,7 +142,7 @@ The `meta` object passed in the mutation's options, if any.
protected clearGcTimeout(): void;
```
-Defined in: [packages/query-core/src/removable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L41)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:7
#### Returns
@@ -162,7 +162,7 @@ Removable.clearGcTimeout
continue(): Promise;
```
-Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:139
Resumes a mutation that is currently paused or was restored from a
dehydrated, still-`pending` state.
@@ -199,11 +199,7 @@ await mutation?.continue()
destroy(): void;
```
-Defined in: [packages/query-core/src/removable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L19)
-
-Clears the pending garbage collection timeout, so the entry is no longer scheduled for removal.
-A subclass may override this to release what it holds on to as well — `Query` also cancels any
-in-flight fetch.
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:4
#### Returns
@@ -223,7 +219,7 @@ Removable.destroy
execute(variables: TVariables): Promise;
```
-Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:170
Runs the mutation function for the given variables through a retryer, and
drives the mutation's state and lifecycle callbacks through to settlement.
@@ -275,7 +271,7 @@ const data = await mutation.execute(variables)
protected optionalRemove(): void;
```
-Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212)
+Defined in: packages/query-core/dist-ts/src/mutation.d.ts:117
#### Returns
@@ -295,7 +291,7 @@ Removable.optionalRemove
protected scheduleGc(): void;
```
-Defined in: [packages/query-core/src/removable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L23)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:5
#### Returns
@@ -315,7 +311,7 @@ Removable.scheduleGc
protected updateGcTime(newGcTime: number | undefined): void;
```
-Defined in: [packages/query-core/src/removable.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L33)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:6
#### Parameters
diff --git a/docs/framework/angular/reference/classes/MutationCache.md b/docs/framework/angular/reference/classes/MutationCache.md
index b64b17cf0e9..54f3e492d55 100644
--- a/docs/framework/angular/reference/classes/MutationCache.md
+++ b/docs/framework/angular/reference/classes/MutationCache.md
@@ -3,7 +3,7 @@ id: MutationCache
title: MutationCache
---
-Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:75
The `MutationCache` is the storage for mutations.
@@ -28,16 +28,16 @@ const unsubscribe = mutationCache.subscribe((event) => {
### Constructor
```ts
-new MutationCache(config: MutationCacheConfig): MutationCache;
+new MutationCache(config?: MutationCacheConfig): MutationCache;
```
-Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:78
#### Parameters
-##### config
+##### config?
-[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}`
+[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md)
#### Returns
@@ -54,10 +54,10 @@ Subscribable.constructor
### config
```ts
-config: MutationCacheConfig = {};
+config: MutationCacheConfig;
```
-Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:77
***
@@ -67,7 +67,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta
protected listeners: Set;
```
-Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L7)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:2
#### Inherited from
@@ -83,7 +83,7 @@ Subscribable.listeners
clear(): void;
```
-Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:99
Removes all mutations from the cache.
@@ -109,7 +109,7 @@ find(filters: MutationFilters):
| undefined;
```
-Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:129
A slightly more advanced method that can be used to get an existing mutation instance from
the cache. If the mutation does not exist, `undefined` is returned.
@@ -163,10 +163,10 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] })
### findAll()
```ts
-findAll(filters: MutationFilters): Mutation[];
+findAll(filters?: MutationFilters): Mutation[];
```
-Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:145
An even more advanced method that can be used to get existing mutation instances from the
cache that match the given filters. If no mutations match, an empty array is returned.
@@ -176,9 +176,9 @@ information about mutations in rare scenarios.
#### Parameters
-##### filters
+##### filters?
-[`MutationFilters`](../interfaces/MutationFilters.md) = `{}`
+[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>
#### Returns
@@ -204,7 +204,7 @@ const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })
getAll(): Mutation[];
```
-Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259)
+Defined in: packages/query-core/dist-ts/src/mutationCache.d.ts:113
Returns all mutations within the cache.
@@ -231,9 +231,7 @@ const mutations = mutationCache.getAll()
hasListeners(): boolean;
```
-Defined in: [packages/query-core/src/subscribable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L41)
-
-Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:5
#### Returns
@@ -253,7 +251,7 @@ Subscribable.hasListeners
protected onSubscribe(): void;
```
-Defined in: [packages/query-core/src/subscribable.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L45)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:6
#### Returns
@@ -273,7 +271,7 @@ Subscribable.onSubscribe
protected onUnsubscribe(): void;
```
-Defined in: [packages/query-core/src/subscribable.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L49)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:7
#### Returns
@@ -293,11 +291,7 @@ Subscribable.onUnsubscribe
subscribe(listener: MutationCacheListener): () => void;
```
-Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27)
-
-Registers a listener to be called on every update this object notifies about. Returns a function
-that removes the listener again — call it to stop listening. The base class never drops a listener
-on its own, though some subclasses clear all of theirs in `destroy()`.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:4
#### Parameters
diff --git a/docs/framework/angular/reference/classes/MutationObserver.md b/docs/framework/angular/reference/classes/MutationObserver.md
index e8ba6146fb3..9c8f8b30daf 100644
--- a/docs/framework/angular/reference/classes/MutationObserver.md
+++ b/docs/framework/angular/reference/classes/MutationObserver.md
@@ -3,7 +3,7 @@ id: MutationObserver
title: MutationObserver
---
-Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:21
Observes a single mutation and derives a `MutationObserverResult` from it.
A framework hook like `useMutation` creates one `MutationObserver` per hook
@@ -50,7 +50,7 @@ const observer = new MutationObserver(queryClient, {
new MutationObserver(client: QueryClient, options: MutationObserverOptions): MutationObserver;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:24
#### Parameters
@@ -69,9 +69,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/
#### Overrides
```ts
-Subscribable<
- MutationObserverListener
->.constructor
+Subscribable>.constructor
```
## Properties
@@ -82,7 +80,7 @@ Subscribable<
protected listeners: Set>;
```
-Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L7)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:2
#### Inherited from
@@ -98,7 +96,7 @@ Subscribable.listeners
options: MutationObserverOptions;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:23
## Methods
@@ -108,7 +106,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/
protected bindMethods(): void;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:25
#### Returns
@@ -122,7 +120,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/
getCurrentResult(): MutationObserverResult;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:52
Returns the observer's current result, derived from the observed
mutation's state (or the default, `idle` state if no mutation has been
@@ -140,9 +138,7 @@ built yet, e.g. before the first `mutate()` call or after `reset()`).
hasListeners(): boolean;
```
-Defined in: [packages/query-core/src/subscribable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L41)
-
-Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:5
#### Returns
@@ -162,7 +158,7 @@ Subscribable.hasListeners
mutate(variables: TVariables, options?: MutateOptions): Promise;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:88
Builds a new `Mutation` in the `MutationCache` using the observer's
current options, detaches this observer from any previously observed
@@ -204,7 +200,7 @@ await observer.mutate(
protected onSubscribe(): void;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:43
#### Returns
@@ -224,7 +220,7 @@ Subscribable.onSubscribe
protected onUnsubscribe(): void;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:44
#### Returns
@@ -244,7 +240,7 @@ Subscribable.onUnsubscribe
reset(): void;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:69
Detaches the observer from the mutation it is currently observing (if
any) and resets the observed result back to its default, `idle` state.
@@ -276,7 +272,7 @@ observer.reset()
setOptions(options: MutationObserverOptions): void;
```
-Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96)
+Defined in: packages/query-core/dist-ts/src/mutationObserver.d.ts:42
Updates the observer's options.
@@ -312,11 +308,7 @@ observer.setOptions({
subscribe(listener: MutationObserverListener): () => void;
```
-Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27)
-
-Registers a listener to be called on every update this object notifies about. Returns a function
-that removes the listener again — call it to stop listening. The base class never drops a listener
-on its own, though some subclasses clear all of theirs in `destroy()`.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:4
#### Parameters
diff --git a/docs/framework/angular/reference/classes/QueriesObserver.md b/docs/framework/angular/reference/classes/QueriesObserver.md
index ebcbcd9cc97..3aafd8b746e 100644
--- a/docs/framework/angular/reference/classes/QueriesObserver.md
+++ b/docs/framework/angular/reference/classes/QueriesObserver.md
@@ -3,7 +3,7 @@ id: QueriesObserver
title: QueriesObserver
---
-Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:37
A `QueriesObserver` watches an array of queries at once, exposing them as
a single array of `QueryObserverResult`s (or, when a `combine` option is
@@ -45,7 +45,7 @@ new QueriesObserver(
options?: QueriesObserverOptions): QueriesObserver;
```
-Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:39
#### Parameters
@@ -79,7 +79,7 @@ Subscribable.constructor
protected listeners: Set;
```
-Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L7)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:2
#### Inherited from
@@ -95,7 +95,7 @@ Subscribable.listeners
destroy(): void;
```
-Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:46
Stops observing all queries: clears all listeners and destroys every
underlying `QueryObserver` this observer manages.
@@ -112,7 +112,7 @@ underlying `QueryObserver` this observer manages.
getCurrentResult(): QueryObserverResult[];
```
-Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:73
Returns the most recently computed array of `QueryObserverResult`s, one
per observed query, in the same order as the queries passed to the
@@ -137,7 +137,7 @@ const data = results.map((result) => result.data)
getObservers(): QueryObserver[];
```
-Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:84
Returns the underlying `QueryObserver` instances this observer manages,
in the same order as the queries passed to the constructor or
@@ -155,7 +155,7 @@ in the same order as the queries passed to the constructor or
getOptimisticResult(queries: QueryObserverOptions[], combine: CombineFn | undefined): [QueryObserverResult[], (r?: QueryObserverResult[]) => TCombinedResult, () => QueryObserverResult[]];
```
-Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:92
The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes
the result for the given (already-defaulted) queries right now, synchronously. Called by
@@ -185,7 +185,7 @@ wrap the results for property-access tracking.
getQueries(): Query[];
```
-Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:78
Returns the underlying `Query` instances currently being observed, in
the same order as the queries passed to the constructor or `setQueries`.
@@ -202,9 +202,7 @@ the same order as the queries passed to the constructor or `setQueries`.
hasListeners(): boolean;
```
-Defined in: [packages/query-core/src/subscribable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L41)
-
-Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:5
#### Returns
@@ -224,7 +222,7 @@ Subscribable.hasListeners
protected onSubscribe(): void;
```
-Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:40
#### Returns
@@ -244,7 +242,7 @@ Subscribable.onSubscribe
protected onUnsubscribe(): void;
```
-Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:41
#### Returns
@@ -264,7 +262,7 @@ Subscribable.onUnsubscribe
setQueries(queries: QueryObserverOptions[], options?: QueriesObserverOptions): void;
```
-Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127)
+Defined in: packages/query-core/dist-ts/src/queriesObserver.d.ts:61
Replaces the set of queries being observed. Existing `QueryObserver`s
are reused for queries that match an already-observed query hash;
@@ -302,11 +300,7 @@ observer.setQueries([
subscribe(listener: QueriesObserverListener): () => void;
```
-Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27)
-
-Registers a listener to be called on every update this object notifies about. Returns a function
-that removes the listener again — call it to stop listening. The base class never drops a listener
-on its own, though some subclasses clear all of theirs in `destroy()`.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:4
#### Parameters
diff --git a/docs/framework/angular/reference/classes/Query.md b/docs/framework/angular/reference/classes/Query.md
index 646028952e1..214b1f36464 100644
--- a/docs/framework/angular/reference/classes/Query.md
+++ b/docs/framework/angular/reference/classes/Query.md
@@ -3,7 +3,7 @@ id: Query
title: Query
---
-Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:154
Represents a single cached query. A `Query` holds the query's key, options,
state (data/error/status), and the observers currently subscribed to it.
@@ -54,7 +54,7 @@ if (query) {
new Query(config: QueryConfig): Query;
```
-Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:161
#### Parameters
@@ -80,7 +80,7 @@ Removable.constructor
gcTime: number;
```
-Defined in: [packages/query-core/src/removable.ts:11](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L11)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:3
#### Inherited from
@@ -96,7 +96,7 @@ Removable.gcTime
observers: QueryObserver[];
```
-Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:160
***
@@ -106,7 +106,7 @@ Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/q
options: QueryOptions;
```
-Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:158
***
@@ -116,7 +116,7 @@ Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/q
queryHash: string;
```
-Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:157
***
@@ -126,7 +126,7 @@ Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/q
queryKey: TQueryKey;
```
-Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:156
***
@@ -136,7 +136,7 @@ Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/q
state: QueryState;
```
-Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:159
## Accessors
@@ -148,7 +148,7 @@ Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/q
get meta(): Record | undefined;
```
-Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:165
The `meta` object passed in the query's options, if any.
@@ -166,7 +166,7 @@ The `meta` object passed in the query's options, if any.
get promise(): Promise | undefined;
```
-Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:172
The promise for the currently in-flight fetch, if the query is fetching.
`undefined` when the query is not fetching.
@@ -183,7 +183,7 @@ The promise for the currently in-flight fetch, if the query is fetching.
cancel(options?: CancelOptions): Promise;
```
-Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:196
Cancels the query's currently in-flight fetch, if any.
- Returns a promise that resolves once the cancellation has settled.
@@ -213,7 +213,7 @@ await query.cancel()
protected clearGcTimeout(): void;
```
-Defined in: [packages/query-core/src/removable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L41)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:7
#### Returns
@@ -233,7 +233,7 @@ Removable.clearGcTimeout
destroy(): void;
```
-Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:204
Clears the query's garbage collection timeout and silently cancels any
in-flight fetch. Called by `QueryCache` when the query is removed from
@@ -261,7 +261,7 @@ Removable.destroy
fetch(options?: QueryOptions, fetchOptions?: FetchOptions): Promise;
```
-Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:309
Fetches the query, i.e. runs its `queryFn` (through any configured
retryer/behavior) and updates the query's state with the result.
@@ -294,7 +294,7 @@ retryer/behavior) and updates the query's state with the result.
getObserversCount(): number;
```
-Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:287
Returns the number of observers currently subscribed to this query.
@@ -318,7 +318,7 @@ if (query.getObserversCount() === 0) {
invalidate(): void;
```
-Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:298
Marks the query as invalidated, unless it is already invalidated. This
updates `state.isInvalidated` and notifies observers, but does not by
@@ -342,7 +342,7 @@ query.invalidate()
isActive(): boolean;
```
-Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:217
Returns `true` if the query has at least one observer for which `enabled`
does not resolve to `false`.
@@ -359,7 +359,7 @@ does not resolve to `false`.
isDisabled(): boolean;
```
-Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:226
Returns `true` if the query is disabled, meaning it will not fetch
automatically.
@@ -380,7 +380,7 @@ automatically.
isFetched(): boolean;
```
-Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:231
Returns `true` if the query has been fetched, i.e. it has resolved with
either data or an error at least once.
@@ -397,7 +397,7 @@ either data or an error at least once.
isStale(): boolean;
```
-Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:253
Returns `true` if the query is stale.
- If the query has observers, defers to whether any observer's current
@@ -427,10 +427,10 @@ if (query.isStale()) {
### isStaleByTime()
```ts
-isStaleByTime(staleTime: number | "static"): boolean;
+isStaleByTime(staleTime?: StaleTime): boolean;
```
-Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:268
Returns `true` if the query's data is stale relative to the given
`staleTime` (defaults to `0`).
@@ -441,9 +441,9 @@ Returns `true` if the query's data is stale relative to the given
#### Parameters
-##### staleTime
+##### staleTime?
-`number` | `"static"`
+[`StaleTime`](../type-aliases/StaleTime.md)
#### Returns
@@ -467,7 +467,7 @@ const isStale = query.isStaleByTime(1000 * 60)
isStatic(): boolean;
```
-Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:236
Returns `true` if the query has at least one observer configured with
`staleTime: 'static'`, meaning it is treated as never stale.
@@ -484,7 +484,7 @@ Returns `true` if the query has at least one observer configured with
protected optionalRemove(): void;
```
-Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:175
#### Returns
@@ -504,7 +504,7 @@ Removable.optionalRemove
reset(): void;
```
-Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:212
Resets the query back to its initial state (the state it had when it was
first created, e.g. any `initialData`), destroying it first to cancel any
@@ -522,7 +522,7 @@ in-flight fetch.
protected scheduleGc(): void;
```
-Defined in: [packages/query-core/src/removable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L23)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:5
#### Returns
@@ -542,7 +542,7 @@ Removable.scheduleGc
setState(state: Partial>): void;
```
-Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334)
+Defined in: packages/query-core/dist-ts/src/query.d.ts:185
Merges the given partial state directly into this query's state, notifying observers. Used
by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a
@@ -566,7 +566,7 @@ user manually trigger a loading/error state or edit the cached data.
protected updateGcTime(newGcTime: number | undefined): void;
```
-Defined in: [packages/query-core/src/removable.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L33)
+Defined in: packages/query-core/dist-ts/src/removable.d.ts:6
#### Parameters
diff --git a/docs/framework/angular/reference/classes/QueryCache.md b/docs/framework/angular/reference/classes/QueryCache.md
index 18520030db7..f55d9dbb86c 100644
--- a/docs/framework/angular/reference/classes/QueryCache.md
+++ b/docs/framework/angular/reference/classes/QueryCache.md
@@ -3,7 +3,7 @@ id: QueryCache
title: QueryCache
---
-Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:85
The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta
information, and state of the queries it contains.
@@ -31,16 +31,16 @@ const unsubscribe = queryCache.subscribe((event) => {
### Constructor
```ts
-new QueryCache(config: QueryCacheConfig): QueryCache;
+new QueryCache(config?: QueryCacheConfig): QueryCache;
```
-Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:88
#### Parameters
-##### config
+##### config?
-[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}`
+[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md)
#### Returns
@@ -57,10 +57,10 @@ Subscribable.constructor
### config
```ts
-config: QueryCacheConfig = {};
+config: QueryCacheConfig;
```
-Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:87
***
@@ -70,7 +70,7 @@ Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanSt
protected listeners: Set;
```
-Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L7)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:2
#### Inherited from
@@ -89,7 +89,7 @@ build(
state?: QueryState): Query;
```
-Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:105
Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or
builds and adds a new one to the cache if none exists yet. Used by framework adapters and
@@ -151,7 +151,7 @@ const query = queryCache.build(queryClient, {
clear(): void;
```
-Defined in: [packages/query-core/src/queryCache.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L228)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:135
Removes all queries from the cache.
@@ -177,7 +177,7 @@ find(filters: WithRequired): Query[];
+findAll(filters?: QueryFilters): Query[];
```
-Defined in: [packages/query-core/src/queryCache.ts:320](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L320)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:196
An even more advanced method that can be used to get existing query instances from the cache
that partially match a query key. If no queries match, an empty array is returned.
@@ -243,9 +243,9 @@ information about queries in rare scenarios.
#### Parameters
-##### filters
+##### filters?
-[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}`
+[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\>
#### Returns
@@ -273,7 +273,7 @@ get(queryHash: string):
| undefined;
```
-Defined in: [packages/query-core/src/queryCache.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L250)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:150
Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none
exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather
@@ -326,7 +326,7 @@ const query = queryCache.get(queryHash)
getAll(): Query[];
```
-Defined in: [packages/query-core/src/queryCache.ts:273](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L273)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:161
Returns all queries within the cache.
@@ -350,9 +350,7 @@ const queries = queryCache.getAll()
hasListeners(): boolean;
```
-Defined in: [packages/query-core/src/subscribable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L41)
-
-Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:5
#### Returns
@@ -372,7 +370,7 @@ Subscribable.hasListeners
protected onSubscribe(): void;
```
-Defined in: [packages/query-core/src/subscribable.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L45)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:6
#### Returns
@@ -392,7 +390,7 @@ Subscribable.onSubscribe
protected onUnsubscribe(): void;
```
-Defined in: [packages/query-core/src/subscribable.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L49)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:7
#### Returns
@@ -412,7 +410,7 @@ Subscribable.onUnsubscribe
remove(query: Query): void;
```
-Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208)
+Defined in: packages/query-core/dist-ts/src/queryCache.d.ts:124
Destroys the given `Query` and removes it from the cache, notifying subscribers with a
`'removed'` event. A no-op if the query is no longer the one currently stored under its hash
@@ -448,11 +446,7 @@ if (query) {
subscribe(listener: QueryCacheListener): () => void;
```
-Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27)
-
-Registers a listener to be called on every update this object notifies about. Returns a function
-that removes the listener again — call it to stop listening. The base class never drops a listener
-on its own, though some subclasses clear all of theirs in `destroy()`.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:4
#### Parameters
diff --git a/docs/framework/angular/reference/classes/QueryClient.md b/docs/framework/angular/reference/classes/QueryClient.md
index 1dcf71fbffb..6b6463f4193 100644
--- a/docs/framework/angular/reference/classes/QueryClient.md
+++ b/docs/framework/angular/reference/classes/QueryClient.md
@@ -3,7 +3,7 @@ id: QueryClient
title: QueryClient
---
-Defined in: [packages/query-core/src/queryClient.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L79)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:24
`QueryClient` is used to interact with a cache of queries and mutations. It owns a
`QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds
@@ -28,16 +28,16 @@ await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts })
### Constructor
```ts
-new QueryClient(config: QueryClientConfig): QueryClient;
+new QueryClient(config?: QueryClientConfig): QueryClient;
```
-Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L89)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:26
#### Parameters
-##### config
+##### config?
-[`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}`
+[`QueryClientConfig`](../interfaces/QueryClientConfig.md)
#### Returns
@@ -51,7 +51,7 @@ Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanSt
cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:441](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L441)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:180
Cancels outgoing fetches for queries matching the given filters. Most useful when performing
optimistic updates, since any outgoing refetch that resolves afterwards would otherwise
@@ -74,7 +74,7 @@ The returned promise never rejects, even if individual cancellations fail.
##### cancelOptions?
-[`CancelOptions`](../interfaces/CancelOptions.md) = `{}`
+[`CancelOptions`](../interfaces/CancelOptions.md)
#### Returns
@@ -94,7 +94,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true })
clear(): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1096)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:430
Clears both the query cache and the mutation cache this client is connected to.
@@ -119,7 +119,7 @@ queryClient.clear()
defaultMutationOptions(options?: T): T;
```
-Defined in: [packages/query-core/src/queryClient.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1070)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:418
The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework
adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the
@@ -152,7 +152,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions;
```
-Defined in: [packages/query-core/src/queryClient.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L983)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:411
Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the
caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the
@@ -203,7 +203,7 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`).
ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>;
```
-Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L747)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:284
#### Type Parameters
@@ -249,7 +249,7 @@ Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This
ensureQueryData(options: EnsureQueryDataOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L198)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:78
#### Type Parameters
@@ -291,7 +291,7 @@ Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method
fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>;
```
-Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L702)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:276
#### Type Parameters
@@ -337,7 +337,7 @@ Use queryClient.infiniteQuery(options) instead. This method will be removed in t
fetchQuery(options: FetchQueryOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L609)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:246
#### Type Parameters
@@ -383,7 +383,7 @@ Use queryClient.query(options) instead. This method will be removed in the next
getDefaultOptions(): DefaultOptions;
```
-Defined in: [packages/query-core/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:336
Returns the default options that were set when creating the client, or via
[QueryClient#setDefaultOptions](#setdefaultoptions).
@@ -409,7 +409,7 @@ const defaultOptions = queryClient.getDefaultOptions()
getMutationCache(): MutationCache;
```
-Defined in: [packages/query-core/src/queryClient.ts:815](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L815)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:323
Returns the mutation cache this client is connected to.
@@ -435,7 +435,7 @@ const mutations = mutationCache.findAll({ status: 'pending' })
getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">;
```
-Defined in: [packages/query-core/src/queryClient.ts:958](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L958)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:404
Returns the default options registered for mutations whose mutation key partially matches
the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered
@@ -465,7 +465,7 @@ const defaultOptions = queryClient.getMutationDefaults(['addPost'])
getQueriesData(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][];
```
-Defined in: [packages/query-core/src/queryClient.ts:244](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L244)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:96
Imperative (non-reactive) way to retrieve the cached data of multiple queries at once.
Only queries matching the given filters are returned; if none match, an empty array is
@@ -517,7 +517,7 @@ const data = queryClient.getQueriesData({ queryKey: ['posts'] })
getQueryCache(): QueryCache;
```
-Defined in: [packages/query-core/src/queryClient.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L799)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:310
Returns the query cache this client is connected to.
@@ -543,7 +543,7 @@ const queries = queryCache.findAll({ queryKey: ['posts'] })
getQueryData(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined;
```
-Defined in: [packages/query-core/src/queryClient.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L184)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:74
Imperative (non-reactive) way to retrieve data for a QueryKey.
Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
@@ -589,7 +589,7 @@ The cached data for the query, or `undefined` if no query with this key has been
getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">;
```
-Defined in: [packages/query-core/src/queryClient.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L901)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:381
Returns the default options registered for queries whose query key partially matches the
given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults
@@ -621,7 +621,7 @@ getQueryState(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>;
```
-Defined in: [packages/query-core/src/queryClient.ts:676](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L676)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:272
Asynchronous method to fetch and cache an infinite query, resolving with an
[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error.
@@ -737,7 +737,7 @@ try {
invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L469)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:194
Marks queries matching the given filters as invalidated. Unlike
[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache.
@@ -760,7 +760,7 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi
##### options?
-[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}`
+[`InvalidateOptions`](../interfaces/InvalidateOptions.md)
#### Returns
@@ -780,7 +780,7 @@ await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active'
isFetching(filters?: TQueryFilters): number;
```
-Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:52
Returns the number of queries in the cache that are currently fetching, optionally
matching a set of filters. This includes background-fetching, loading new pages, and
@@ -818,7 +818,7 @@ if (queryClient.isFetching()) {
isMutating(filters?: TMutationFilters): number;
```
-Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:64
Returns the number of mutations in the cache that are currently pending, optionally
matching a set of filters.
@@ -855,7 +855,7 @@ if (queryClient.isMutating()) {
mount(): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:33
Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start
listening for focus/online events and resume paused mutations. Ref-counted via an internal
@@ -874,7 +874,7 @@ the shared listeners until the last one unmounts.
prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:280
#### Type Parameters
@@ -920,7 +920,7 @@ Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.ca
prefetchQuery(options: FetchQueryOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:250
#### Type Parameters
@@ -962,7 +962,7 @@ Use queryClient.query(options) instead. You can swallow errors with `.catch(noop
query(options: QueryExecuteOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:563](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L563)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:242
Asynchronous method to fetch and cache a query, resolving with the data or throwing with
the error.
@@ -1039,7 +1039,7 @@ try {
refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:506](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L506)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:210
Refetches queries matching the given filters, regardless of whether they are stale. Without
filters, every query in the cache is refetched. Queries that are disabled, or static (only
@@ -1063,7 +1063,7 @@ not reject on individual query failures unless `throwOnError` is set.
##### options?
-[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}`
+[`RefetchOptions`](../interfaces/RefetchOptions.md)
#### Returns
@@ -1084,7 +1084,7 @@ await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' })
removeQueries(filters?: QueryFilters): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:385](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L385)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:155
Removes queries from the cache that match the given filters. Unlike
[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes
@@ -1121,7 +1121,7 @@ queryClient.removeQueries({ queryKey: ['posts'], exact: true })
resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:406](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L406)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:166
Resets queries matching the given filters back to their initial state (e.g. any
`initialData`), notifying subscribers rather than removing them. Active queries among the
@@ -1161,7 +1161,7 @@ await queryClient.resetQueries({ queryKey: ['posts'], exact: true })
resumePausedMutations(): Promise;
```
-Defined in: [packages/query-core/src/queryClient.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L780)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:297
Resumes mutations that were paused because there was no network connection. Does nothing
(resolving immediately) if the client is currently offline.
@@ -1187,7 +1187,7 @@ await queryClient.resumePausedMutations()
setDefaultOptions(options: DefaultOptions): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:852](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L852)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:354
Dynamically sets the default options for this client, overwriting any previously defined
default options.
@@ -1227,7 +1227,7 @@ queryClient.setDefaultOptions({
setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L930)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:393
Sets default options for mutations whose mutation key partially matches the given
`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration
@@ -1286,7 +1286,7 @@ setQueriesData(
options?: SetDataOptions): [readonly unknown[], TQueryFnData | undefined][];
```
-Defined in: [packages/query-core/src/queryClient.ts:328](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L328)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:132
Synchronous way to immediately update the cached data of multiple queries at once, using
filters or partial query key matching. Only queries that already exist and match the given
@@ -1343,7 +1343,7 @@ setQueryData(
options?: SetDataOptions): NoInfer | undefined;
```
-Defined in: [packages/query-core/src/queryClient.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L278)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:118
Synchronous way to immediately update a query's cached data. If the updater (or the value
passed) resolves to `undefined`, the cache is left untouched and no query is created;
@@ -1412,7 +1412,7 @@ queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost])
setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L871)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:370
Sets default options for queries whose query key partially matches the given `queryKey`.
@@ -1469,7 +1469,7 @@ await queryClient.query({ queryKey: ['posts'] })
unmount(): void;
```
-Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127)
+Defined in: packages/query-core/dist-ts/src/queryClient.d.ts:39
The inverse of [QueryClient#mount](#mount) — called by a framework adapter's
`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online
diff --git a/docs/framework/angular/reference/classes/QueryObserver.md b/docs/framework/angular/reference/classes/QueryObserver.md
index ba20c873925..a3e0b017e0e 100644
--- a/docs/framework/angular/reference/classes/QueryObserver.md
+++ b/docs/framework/angular/reference/classes/QueryObserver.md
@@ -3,7 +3,7 @@ id: QueryObserver
title: QueryObserver
---
-Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:29
A `QueryObserver` watches a single query in the `QueryCache` and computes a
`QueryObserverResult` from its state, recomputing and notifying subscribers
@@ -63,7 +63,7 @@ const unsubscribe = observer.subscribe((result) => {
new QueryObserver(client: QueryClient, options: QueryObserverOptions): QueryObserver;
```
-Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:32
#### Parameters
@@ -93,7 +93,7 @@ Subscribable>.constructor
protected listeners: Set>;
```
-Defined in: [packages/query-core/src/subscribable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L7)
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:2
#### Inherited from
@@ -109,7 +109,7 @@ Subscribable.listeners
options: QueryObserverOptions;
```
-Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:31
## Methods
@@ -119,7 +119,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan
protected bindMethods(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:33
#### Returns
@@ -133,7 +133,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/Ta
protected createResult(query: Query, options: QueryObserverOptions): QueryObserverResult;
```
-Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:136
#### Parameters
@@ -157,7 +157,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/Ta
destroy(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:53
Stops observing the current query: clears all listeners, cancels the
stale and refetch-interval timers, and removes this observer from the
@@ -175,7 +175,7 @@ query it was observing.
protected fetch(fetchOptions: ObserverFetchOptions): Promise>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:135
#### Parameters
@@ -195,7 +195,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/Ta
fetchOptimistic(options: QueryObserverOptions): Promise>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:134
Fetches a query defined by the given options without affecting this
observer's own tracked query or result, and returns a promise that
@@ -231,7 +231,7 @@ console.log(result.data)
getCurrentQuery(): Query;
```
-Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:106
Returns the `Query` instance this observer is currently observing.
@@ -247,7 +247,7 @@ Returns the `Query` instance this observer is currently observing.
getCurrentResult(): QueryObserverResult;
```
-Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:88
Returns the most recently computed `QueryObserverResult` for the
observed query. This is a point-in-time read; to be notified of updates
@@ -273,7 +273,7 @@ console.log(result.status, result.data)
getOptimisticResult(options: DefaultedQueryObserverOptions): QueryObserverResult;
```
-Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:75
Computes the result the observer would produce for the given (already-defaulted) options
right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
@@ -298,9 +298,7 @@ returned value is available synchronously, ahead of `setOptions` triggering an a
hasListeners(): boolean;
```
-Defined in: [packages/query-core/src/subscribable.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L41)
-
-Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:5
#### Returns
@@ -320,7 +318,7 @@ Subscribable.hasListeners
protected onSubscribe(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:34
#### Returns
@@ -340,7 +338,7 @@ Subscribable.onSubscribe
protected onUnsubscribe(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:35
#### Returns
@@ -357,19 +355,19 @@ Subscribable.onUnsubscribe
### refetch()
```ts
-refetch(__namedParameters: RefetchOptions): Promise>;
+refetch(__namedParameters?: RefetchOptions): Promise>;
```
-Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:117
Refetches the observed query and returns a promise that resolves with
the resulting `QueryObserverResult`.
#### Parameters
-##### \_\_namedParameters
+##### \_\_namedParameters?
-[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}`
+[`RefetchOptions`](../interfaces/RefetchOptions.md)
#### Returns
@@ -390,7 +388,7 @@ console.log(result.data)
setOptions(options: QueryObserverOptions): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:68
Updates the observer's options. This will re-resolve the query being
observed (switching to a different query if the `queryKey` changed),
@@ -424,7 +422,7 @@ observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })
shouldFetchOnReconnect(): boolean;
```
-Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:41
Returns whether the observed query is currently stale and configured
(via the `refetchOnReconnect` option) to refetch when the network
@@ -442,7 +440,7 @@ reconnects.
shouldFetchOnWindowFocus(): boolean;
```
-Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:47
Returns whether the observed query is currently stale and configured
(via the `refetchOnWindowFocus` option) to refetch when the window
@@ -460,11 +458,7 @@ regains focus.
subscribe(listener: QueryObserverListener): () => void;
```
-Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27)
-
-Registers a listener to be called on every update this object notifies about. Returns a function
-that removes the listener again — call it to stop listening. The base class never drops a listener
-on its own, though some subclasses clear all of theirs in `destroy()`.
+Defined in: packages/query-core/dist-ts/src/subscribable.d.ts:4
#### Parameters
@@ -506,8 +500,8 @@ Subscribable.subscribe
```ts
trackProp(key:
- | "error"
| "data"
+ | "error"
| "isError"
| "isPending"
| "isLoading"
@@ -533,7 +527,7 @@ trackProp(key:
| "fetchStatus"): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:102
Records that the given `QueryObserverResult` property was read, so a subsequent update only
notifies this observer if a tracked property actually changed. Normally called indirectly via
@@ -544,7 +538,7 @@ access themselves (e.g. through their own reactivity system) instead of via the
##### key
-`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"`
+`"data"` | `"error"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"`
#### Returns
@@ -556,8 +550,8 @@ access themselves (e.g. through their own reactivity system) instead of via the
```ts
trackResult(result: QueryObserverResult, onPropTracked?: (key:
- | "error"
| "data"
+ | "error"
| "isError"
| "isPending"
| "isLoading"
@@ -583,7 +577,7 @@ trackResult(result: QueryObserverResult, onPropTracked?: (key:
| "fetchStatus") => void): QueryObserverResult;
```
-Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:95
Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework
@@ -599,8 +593,8 @@ properties you actually read" behavior.
##### onPropTracked?
(`key`:
- \| `"error"`
\| `"data"`
+ \| `"error"`
\| `"isError"`
\| `"isPending"`
\| `"isLoading"`
@@ -637,7 +631,7 @@ properties you actually read" behavior.
updateResult(): void;
```
-Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735)
+Defined in: packages/query-core/dist-ts/src/queryObserver.d.ts:142
Recomputes and stores the current result from the current query/options, notifying listeners
if it changed. Framework adapters call this right after subscribing to make sure no query
diff --git a/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md
index 0458c88f4fc..38c1127b2c7 100644
--- a/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md
+++ b/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md
@@ -7,7 +7,7 @@ title: defaultShouldDehydrateMutation
function defaultShouldDehydrateMutation(mutation: Mutation): boolean;
```
-Defined in: [packages/query-core/src/hydration.ts:178](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L178)
+Defined in: packages/query-core/dist-ts/src/hydration.d.ts:77
The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are
currently paused (e.g. paused by `networkMode` while offline).
diff --git a/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md
index 736579349d7..35b7cd8d815 100644
--- a/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md
+++ b/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md
@@ -7,7 +7,7 @@ title: defaultShouldDehydrateQuery
function defaultShouldDehydrateQuery(query: Query): boolean;
```
-Defined in: [packages/query-core/src/hydration.ts:186](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L186)
+Defined in: packages/query-core/dist-ts/src/hydration.d.ts:82
The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is
`'success'`.
diff --git a/docs/framework/angular/reference/functions/dehydrate.md b/docs/framework/angular/reference/functions/dehydrate.md
index 201200efdfa..ff2ac4eae35 100644
--- a/docs/framework/angular/reference/functions/dehydrate.md
+++ b/docs/framework/angular/reference/functions/dehydrate.md
@@ -4,10 +4,10 @@ title: dehydrate
---
```ts
-function dehydrate(client: QueryClient, options: DehydrateOptions): DehydratedState;
+function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
```
-Defined in: [packages/query-core/src/hydration.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L208)
+Defined in: packages/query-core/dist-ts/src/hydration.d.ts:101
Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`,
typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`.
@@ -21,9 +21,9 @@ falling back to the client's `dehydrate` default options, and finally to `defaul
[`QueryClient`](../classes/QueryClient.md)
-### options
+### options?
-[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}`
+[`DehydrateOptions`](../interfaces/DehydrateOptions.md)
## Returns
diff --git a/docs/framework/angular/reference/functions/dehydrateQuery.md b/docs/framework/angular/reference/functions/dehydrateQuery.md
index 0dcd0904691..cb822128162 100644
--- a/docs/framework/angular/reference/functions/dehydrateQuery.md
+++ b/docs/framework/angular/reference/functions/dehydrateQuery.md
@@ -10,7 +10,7 @@ function dehydrateQuery(
shouldRedactErrors?: (error: unknown) => boolean): DehydratedQuery;
```
-Defined in: [packages/query-core/src/hydration.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L149)
+Defined in: packages/query-core/dist-ts/src/hydration.d.ts:72
Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.
`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the
diff --git a/docs/framework/angular/reference/functions/experimental_streamedQuery.md b/docs/framework/angular/reference/functions/experimental_streamedQuery.md
index 29a8ae5d889..a361f08f15f 100644
--- a/docs/framework/angular/reference/functions/experimental_streamedQuery.md
+++ b/docs/framework/angular/reference/functions/experimental_streamedQuery.md
@@ -4,10 +4,10 @@ title: experimental_streamedQuery
---
```ts
-function experimental_streamedQuery(streamFn: StreamedQueryParams): (context: object) => TData | Promise;
+function experimental_streamedQuery(streamFn: StreamedQueryParams): QueryFunction;
```
-Defined in: [packages/query-core/src/streamedQuery.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L68)
+Defined in: packages/query-core/dist-ts/src/streamedQuery.d.ts:53
This is a helper function to create a query function that streams data from an AsyncIterable.
Data will be an Array of all the chunks received.
@@ -38,45 +38,7 @@ The function that returns an AsyncIterable to stream data from.
## Returns
-```ts
-(context: object): TData | Promise;
-```
-
-### Parameters
-
-#### context
-
-##### client
-
-[`QueryClient`](../classes/QueryClient.md)
-
-##### direction?
-
-`unknown`
-
-**Deprecated**
-
-if you want access to the direction, you can add it to the pageParam
-
-##### meta
-
-`Record`\<`string`, `unknown`\> \| `undefined`
-
-##### pageParam?
-
-`unknown`
-
-##### queryKey
-
-`TQueryKey`
-
-##### signal
-
-`AbortSignal`
-
-### Returns
-
-`TData` \| `Promise`\<`TData`\>
+[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\>
## Example
diff --git a/docs/framework/angular/reference/functions/hashKey.md b/docs/framework/angular/reference/functions/hashKey.md
index 82e2b70512e..08c5c0d2e8d 100644
--- a/docs/framework/angular/reference/functions/hashKey.md
+++ b/docs/framework/angular/reference/functions/hashKey.md
@@ -7,7 +7,7 @@ title: hashKey
function hashKey(queryKey: readonly unknown[]): string;
```
-Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284)
+Defined in: packages/query-core/dist-ts/src/utils.d.ts:133
Default query & mutation keys hash function.
Hashes the value into a stable hash.
diff --git a/docs/framework/angular/reference/functions/hydrate.md b/docs/framework/angular/reference/functions/hydrate.md
index 435603b3af4..f91d93e1092 100644
--- a/docs/framework/angular/reference/functions/hydrate.md
+++ b/docs/framework/angular/reference/functions/hydrate.md
@@ -10,7 +10,7 @@ function hydrate(
options?: HydrateOptions): void;
```
-Defined in: [packages/query-core/src/hydration.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L265)
+Defined in: packages/query-core/dist-ts/src/hydration.d.ts:119
Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the
client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.
diff --git a/docs/framework/angular/reference/functions/infiniteQueryOptions.md b/docs/framework/angular/reference/functions/infiniteQueryOptions.md
index 38986e086e8..12439949a44 100644
--- a/docs/framework/angular/reference/functions/infiniteQueryOptions.md
+++ b/docs/framework/angular/reference/functions/infiniteQueryOptions.md
@@ -9,7 +9,7 @@ title: infiniteQueryOptions
function infiniteQueryOptions(options: DefinedInitialDataInfiniteOptions): CreateInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>;
```
-Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:181](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L181)
+Defined in: [packages/angular-query/src/infinite-query-options.ts:180](https://github.com/TanStack/query/blob/main/packages/angular-query/src/infinite-query-options.ts#L180)
You can generally pass everything to `infiniteQueryOptions` that you can also pass to
`injectInfiniteQuery`. These options can be shared across functions and imperative APIs such as
@@ -65,7 +65,7 @@ automatically as the user scrolls.
### Example
```angular-ts
-import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query-experimental'
+import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query'
export const projectsOptions = infiniteQueryOptions({
queryKey: ['projects'],
@@ -100,7 +100,7 @@ export class Projects {
function infiniteQueryOptions(options: UnusedSkipTokenInfiniteOptions): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag, TError>;
```
-Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:255](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L255)
+Defined in: [packages/angular-query/src/infinite-query-options.ts:254](https://github.com/TanStack/query/blob/main/packages/angular-query/src/infinite-query-options.ts#L254)
You can generally pass everything to `infiniteQueryOptions` that you can also pass to
`injectInfiniteQuery`. These options can be shared across functions and imperative APIs such as
@@ -151,7 +151,7 @@ automatically as the user scrolls.
A parameterized factory, so the same options object can be reused per `postId`:
```angular-ts
-import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query-experimental'
+import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query'
export const commentsOptions = (postId: string) =>
infiniteQueryOptions({
@@ -195,7 +195,7 @@ export class Comments {
function infiniteQueryOptions(options: UndefinedInitialDataInfiniteOptions): CreateInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>;
```
-Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:329](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L329)
+Defined in: [packages/angular-query/src/infinite-query-options.ts:328](https://github.com/TanStack/query/blob/main/packages/angular-query/src/infinite-query-options.ts#L328)
You can generally pass everything to `infiniteQueryOptions` that you can also pass to
`injectInfiniteQuery`. These options can be shared across functions and imperative APIs such as
@@ -246,7 +246,7 @@ automatically as the user scrolls) and that use `skipToken` to disable the query
A parameterized factory, so the same options object can be reused per `postId`:
```angular-ts
-import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query-experimental'
+import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query'
export const commentsOptions = (postId: string) =>
infiniteQueryOptions({
diff --git a/docs/framework/angular/reference/functions/injectInfiniteQuery.md b/docs/framework/angular/reference/functions/injectInfiniteQuery.md
index 39aecc1d173..c81c036462d 100644
--- a/docs/framework/angular/reference/functions/injectInfiniteQuery.md
+++ b/docs/framework/angular/reference/functions/injectInfiniteQuery.md
@@ -6,17 +6,13 @@ title: injectInfiniteQuery
## Call Signature
```ts
-function injectInfiniteQuery(injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions, options?: InjectInfiniteQueryOptions): DefinedCreateInfiniteQueryResult;
+function injectInfiniteQuery(optionsFn: () => DefinedInitialDataInfiniteOptions): DefinedCreateInfiniteQueryResult;
```
-Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:83](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L83)
+Defined in: [packages/angular-query/src/inject-infinite-query.ts:39](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-infinite-query.ts#L39)
-The options for `injectInfiniteQuery` are identical to `injectQuery`, with the addition of
-`initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. Infinite queries can
-additively "load more" data onto an existing set of data, or "infinite scroll".
-
-This overload is selected when `initialData` is set on the options returned by `injectInfiniteQueryFn`,
-so the resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`).
+This overload is selected when `initialData` is set, so the resulting `data` signal is never `undefined`
+(unless a `select` changes `TData` to include `undefined`).
### Type Parameters
@@ -42,79 +38,35 @@ so the resulting `data` signal is never `undefined` (unless a `select` changes `
### Parameters
-#### injectInfiniteQueryFn
+#### optionsFn
() => [`DefinedInitialDataInfiniteOptions`](../type-aliases/DefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>
-A function returning the [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfiniteOptions.md) to use —
-everything you can pass to `injectInfiniteQuery`, with `initialData` set. Similar to `computed` from
-Angular, this function runs in the reactive context, so signals read inside it drive the query.
-
-#### options?
-
-[`InjectInfiniteQueryOptions`](../interfaces/InjectInfiniteQueryOptions.md)
-
-Additional configuration.
+A function returning infinite-query options with `initialData` set. Similar to
+`computed` from Angular, this function runs in the reactive context.
### Returns
[`DefinedCreateInfiniteQueryResult`](../type-aliases/DefinedCreateInfiniteQueryResult.md)\<`TData`, `TError`\>
-The same signals as `injectQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,
-`hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data().pages` and
-`data().pageParams` are also added, as long as a `select` doesn't change `TData` away from its default
-`InfiniteData` shape.
-
-### Remarks
-
-Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default
-refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user
-actions, or add conditions like `hasNextPage() && !isFetching()`.
+The infinite query result, typed so that `data` is never `undefined`.
### See
-[infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `injectInfiniteQuery` and imperative APIs
-like `queryClient.fetchInfiniteQuery`.
-
-### Example
-
-```angular-ts
-@Component({
- selector: 'projects',
- template: `
-
-
- @for (page of projectsQuery.data().pages; track $index) {
- @for (project of page.projects; track project.id) {
-
{{ project.name }}
- }
- }
-
- `,
-})
-export class Projects {
- readonly projectsQuery = injectInfiniteQuery(() => ({
- queryKey: ['projects'],
- queryFn: ({ pageParam }) => fetchProjects(pageParam),
- initialPageParam: 0,
- getNextPageParam: (lastPage) => lastPage.nextId,
- initialData: { pages: [], pageParams: [] },
- }))
-}
-```
+ - https://tanstack.com/query/latest/docs/framework/angular/guides/infinite-queries
+ - [infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `injectInfiniteQuery` and
+`queryClient.infiniteQuery`.
## Call Signature
```ts
-function injectInfiniteQuery(injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult;
+function injectInfiniteQuery(optionsFn: () => UndefinedInitialDataInfiniteOptions): CreateInfiniteQueryResult;
```
-Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:239](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L239)
+Defined in: [packages/angular-query/src/inject-infinite-query.ts:95](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-infinite-query.ts#L95)
-Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a
-unique key. Infinite queries can additively "load more" data onto an existing set of data, or
-"infinite scroll".
+Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
+Infinite queries can additively "load more" data onto an existing set of data or support infinite scroll.
### Type Parameters
@@ -140,155 +92,51 @@ unique key. Infinite queries can additively "load more" data onto an existing se
### Parameters
-#### injectInfiniteQueryFn
+#### optionsFn
() => [`UndefinedInitialDataInfiniteOptions`](../type-aliases/UndefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>
-A function returning the [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataInfiniteOptions.md) to use
-— everything you can pass to `injectInfiniteQuery`. Similar to `computed` from Angular, this function runs
-in the reactive context, so signals read inside it drive the query.
-
-#### options?
-
-[`InjectInfiniteQueryOptions`](../interfaces/InjectInfiniteQueryOptions.md)
-
-Additional configuration.
+A function that returns infinite query options. Similar to `computed` from Angular,
+this function runs in the reactive context, so signals read inside it drive the query.
### Returns
[`CreateInfiniteQueryResult`](../type-aliases/CreateInfiniteQueryResult.md)\<`TData`, `TError`\>
-The same signals as `injectQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,
-`hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data().pages` and
-`data().pageParams` are also added, as long as a `select` doesn't change `TData` away from its default
-`InfiniteData` shape.
-
-### Remarks
-
-Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default
-refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user
-actions, or add conditions like `hasNextPage() && !isFetching()`. This is the only overload that accepts
-`queryFn: skipToken`, shown below.
+The infinite query result.
### See
-[infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `injectInfiniteQuery` and imperative APIs
-like `queryClient.fetchInfiniteQuery`.
-
-### Examples
+ - https://tanstack.com/query/latest/docs/framework/angular/guides/infinite-queries
+ - [infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `injectInfiniteQuery` and
+`queryClient.infiniteQuery`.
-Fetching the next page from a button click:
-```angular-ts
-@Component({
- selector: 'projects-list',
- template: `
-
- @for (page of projectsQuery.data()?.pages; track $index) {
- @for (project of page.projects; track project.id) {
-
{{ project.name }}
- }
- }
-
-
- `,
-})
-export class ProjectsList {
- readonly projectsQuery = injectInfiniteQuery(() => ({
- queryKey: ['projects'],
- queryFn: ({ pageParam }) => fetchProjects(pageParam),
- initialPageParam: 0,
- getNextPageParam: (lastPage) => lastPage.nextId,
- }))
-}
-```
-
-Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a sentinel
-element after the list:
-```angular-ts
-@Component({
- selector: 'projects-list',
- template: `
-
- @for (page of projectsQuery.data()?.pages; track $index) {
- @for (project of page.projects; track project.id) {
-
- @for (page of commentsQuery.data().pages; track $index) {
- @for (comment of page.comments; track comment.id) {
-
{{ comment.text }}
- }
+ @for (page of query.data().pages; track $index) {
+ @for (project of page; track project.id) {
+
{{ project.name }}
}
-
+ }
+
}
`,
})
-export class Comments {
- readonly postId = signal(undefined)
-
- readonly commentsQuery = injectInfiniteQuery(() => ({
- queryKey: ['post', this.postId(), 'comments'],
- queryFn:
- this.postId() != null
- ? ({ pageParam }) => fetchComments(this.postId()!, pageParam)
- : skipToken,
+export class Projects {
+ readonly query = injectInfiniteQuery(() => ({
+ queryKey: ['projects'],
+ queryFn: ({ pageParam }) => fetchProjects(pageParam),
initialPageParam: 0,
- getNextPageParam: (lastPage) => lastPage.nextId,
+ getNextPageParam: (lastPage) => lastPage.nextCursor,
}))
}
```
@@ -296,15 +144,14 @@ export class Comments {
## Call Signature
```ts
-function injectInfiniteQuery(injectInfiniteQueryFn: () => CreateInfiniteQueryOptions, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult;
+function injectInfiniteQuery(optionsFn: () => CreateInfiniteQueryOptions): CreateInfiniteQueryResult;
```
-Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:267](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L267)
+Defined in: [packages/angular-query/src/inject-infinite-query.ts:121](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-infinite-query.ts#L121)
This overload accepts the general [CreateInfiniteQueryOptions](../interfaces/CreateInfiniteQueryOptions.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 `injectInfiniteQuery` in your own helper function that forwards caller-provided
-options.
+`initialData`-aware overloads above, so whether `data` is defined can't be inferred from the call
+site — useful when wrapping `injectInfiniteQuery` in your own helper.
### Type Parameters
@@ -330,21 +177,19 @@ options.
### Parameters
-#### injectInfiniteQueryFn
+#### optionsFn
() => [`CreateInfiniteQueryOptions`](../interfaces/CreateInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>
-A function that returns infinite query options. Similar to `computed` from
-Angular, this function runs in the reactive context, so signals read inside it drive the query.
-
-#### options?
-
-[`InjectInfiniteQueryOptions`](../interfaces/InjectInfiniteQueryOptions.md)
-
-Additional configuration.
+A function that returns infinite query options. Similar to `computed` from Angular,
+this function runs in the reactive context, so signals read inside it drive the query.
### Returns
[`CreateInfiniteQueryResult`](../type-aliases/CreateInfiniteQueryResult.md)\<`TData`, `TError`\>
The infinite query result.
+
+### See
+
+https://tanstack.com/query/latest/docs/framework/angular/guides/infinite-queries
diff --git a/docs/framework/angular/reference/functions/injectIsFetching.md b/docs/framework/angular/reference/functions/injectIsFetching.md
index ce629a0cf3f..52f5fcc90a6 100644
--- a/docs/framework/angular/reference/functions/injectIsFetching.md
+++ b/docs/framework/angular/reference/functions/injectIsFetching.md
@@ -4,63 +4,26 @@ title: injectIsFetching
---
```ts
-function injectIsFetching(filters?: QueryFilters, options?: InjectIsFetchingOptions): Signal;
+function injectIsFetching(filters: () => QueryFilters): Signal;
```
-Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:63](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L63)
+Defined in: [packages/angular-query/src/inject-is-fetching.ts:15](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-is-fetching.ts#L15)
Injects a signal that tracks the number of queries that your application is loading or fetching in the
background (useful for app-wide loading indicators).
-## Parameters
-
-### filters?
-
-[`QueryFilters`](../interfaces/QueryFilters.md)\
+Can be used for app-wide loading indicators
-The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries.
+## Parameters
-### options?
+### filters
-[`InjectIsFetchingOptions`](../interfaces/InjectIsFetchingOptions.md)
+() => [`QueryFilters`](../interfaces/QueryFilters.md)
-Additional configuration
+A reactive factory for the filters.
## Returns
`Signal`\<`number`\>
-A `Signal` with the number of queries that your application is currently loading or fetching in
-the background.
-
-## Examples
-
-```angular-ts
-@Component({
- selector: 'posts-fetching-indicator',
- template: `
- @if (isFetchingPosts()) {
- Refreshing posts...
- }
- `,
-})
-export class PostsFetchingIndicator {
- // How many queries matching the posts prefix are fetching?
- readonly isFetchingPosts = injectIsFetching({ queryKey: ['posts'] })
-}
-```
-
-A global loading indicator for any query fetching in the background, not just the ones on screen:
-```angular-ts
-@Component({
- selector: 'global-loading-indicator',
- template: `
- @if (isFetching()) {
-
Queries are fetching in the background...
- }
- `,
-})
-export class GlobalLoadingIndicator {
- readonly isFetching = injectIsFetching()
-}
-```
+signal with number of loading or fetching queries.
diff --git a/docs/framework/angular/reference/functions/injectIsMutating.md b/docs/framework/angular/reference/functions/injectIsMutating.md
index 409d7c1653f..8f97eade417 100644
--- a/docs/framework/angular/reference/functions/injectIsMutating.md
+++ b/docs/framework/angular/reference/functions/injectIsMutating.md
@@ -4,47 +4,26 @@ title: injectIsMutating
---
```ts
-function injectIsMutating(filters?: MutationFilters, options?: InjectIsMutatingOptions): Signal;
+function injectIsMutating(filters: () => MutationFilters): Signal;
```
-Defined in: [packages/angular-query-experimental/src/inject-is-mutating.ts:46](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L46)
+Defined in: [packages/angular-query/src/inject-is-mutating.ts:15](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-is-mutating.ts#L15)
Injects a signal that tracks the number of mutations that your application currently has `pending`
(useful for app-wide loading indicators).
-## Parameters
-
-### filters?
-
-[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>
+Can be used for app-wide loading indicators
-The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations.
+## Parameters
-### options?
+### filters
-[`InjectIsMutatingOptions`](../interfaces/InjectIsMutatingOptions.md)
+() => [`MutationFilters`](../interfaces/MutationFilters.md)
-Additional configuration
+A reactive factory for the filters.
## Returns
`Signal`\<`number`\>
-A `Signal` with the number of mutations that your application currently has `pending`.
-
-## Example
-
-```angular-ts
-@Component({
- selector: 'posts-mutating-indicator',
- template: `
- @if (isMutatingPosts()) {
- Saving posts...
- }
- `,
-})
-export class PostsMutatingIndicator {
- // How many mutations matching the posts prefix are in progress?
- readonly isMutatingPosts = injectIsMutating({ mutationKey: ['posts'] })
-}
-```
+A read-only signal with the number of fetching mutations.
diff --git a/docs/framework/angular/reference/functions/injectIsRestoring.md b/docs/framework/angular/reference/functions/injectIsRestoring.md
index 2fbe1dfee3a..6796ffdf83f 100644
--- a/docs/framework/angular/reference/functions/injectIsRestoring.md
+++ b/docs/framework/angular/reference/functions/injectIsRestoring.md
@@ -4,26 +4,16 @@ title: injectIsRestoring
---
```ts
-function injectIsRestoring(options?: InjectIsRestoringOptions): Signal;
+function injectIsRestoring(): Signal;
```
-Defined in: [packages/angular-query-experimental/src/inject-is-restoring.ts:35](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-restoring.ts#L35)
+Defined in: [packages/angular-query/src/inject-is-restoring.ts:21](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-is-restoring.ts#L21)
-Injects a signal that tracks whether a restore (e.g. from a persisted client, wired up via
-`provideIsRestoring`) is currently in progress. `injectQuery` and friends also check this internally to
-avoid race conditions between the restore and initializing queries.
-
-## Parameters
-
-### options?
-
-`InjectIsRestoringOptions`
-
-Additional configuration
+Injects a readonly signal that is true while the persistence integration restores
+cached query data. Returns false when no restoration is in progress.
## Returns
`Signal`\<`boolean`\>
-A readonly `Signal` — `true` while a restore is in progress, `false` otherwise (the
-default when no `provideIsRestoring` provider is registered).
+The current restoration state.
diff --git a/docs/framework/angular/reference/functions/injectMutation.md b/docs/framework/angular/reference/functions/injectMutation.md
index 2a31bca1e7d..19fdc7c820c 100644
--- a/docs/framework/angular/reference/functions/injectMutation.md
+++ b/docs/framework/angular/reference/functions/injectMutation.md
@@ -4,13 +4,13 @@ title: injectMutation
---
```ts
-function injectMutation(injectMutationFn: () => CreateMutationOptions, options?: InjectMutationOptions): CreateMutationResult;
+function injectMutation(optionsFn: () => CreateMutationOptions): CreateMutationResult;
```
-Defined in: [packages/angular-query-experimental/src/inject-mutation.ts:174](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L174)
+Defined in: [packages/angular-query/src/inject-mutation.ts:51](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-mutation.ts#L51)
-Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
-`injectMutation` is the function for that. Unlike queries, mutations are not run automatically.
+Injects a mutation: an imperative function that can be invoked which typically performs server side effects.
+Unlike queries, mutations are not run automatically.
## Type Parameters
@@ -32,153 +32,40 @@ Unlike queries, mutations are typically used to create/update/delete data or per
## Parameters
-### injectMutationFn
+### optionsFn
() => [`CreateMutationOptions`](../interfaces/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>
-A function that returns mutation options. Similar to `computed` from Angular,
-this function runs in the reactive context, so signals read inside it drive the mutation's options.
-
-### options?
-
-[`InjectMutationOptions`](../interfaces/InjectMutationOptions.md)
-
-Additional configuration
+A function that returns mutation options. Similar to `computed` from Angular, this
+function runs in the reactive context, so signals read inside it drive the mutation.
## Returns
[`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>
-The mutation result. Value fields are exposed as a `Signal` — read `data`/`error` by calling them
-(e.g. `mutation.data()`) — while function fields (`mutate`, `mutateAsync`, `reset`) are called directly,
-unchanged. `isSuccess`/`isError`/`isPending`/`isIdle` are type-guard methods you can call to narrow whether
-`data` is defined.
-
-## Remarks
-
-`mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a
-second argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to
-the shared mutation definition. Callbacks defined in `injectMutationFn` fire for every mutation; per-call
-callbacks fire only for the latest call you've made — `mutateAsync` gives you a promise per call instead,
-so you can await `Promise.all`/`Promise.allSettled` over several calls and see each one's outcome.
+The mutation result, including `mutate` and `mutateAsync`.
## See
-[mutationOptions](mutationOptions.md) to share these options across multiple `injectMutation` call sites, or to look
-the mutation up elsewhere via its `mutationKey` (e.g. with `injectMutationState`).
-
-## Examples
-
-```angular-ts
-@Component({
- selector: 'todos',
- template: `
- @if (addMutation.isPending()) {
- Adding todo...
- } @else if (addMutation.isError()) {
-
An error occurred: {{ addMutation.error()?.message }}
- }
-
- `,
-})
-export class Todos {
- readonly #queryClient = inject(QueryClient)
-
- readonly addMutation = injectMutation(() => ({
- mutationFn: addTodo,
- onSuccess: () => this.#queryClient.invalidateQueries({ queryKey: ['todos'] }),
- }))
-}
-```
+ - https://tanstack.com/query/latest/docs/framework/angular/guides/mutations
+ - [mutationOptions](mutationOptions.md) to share these options between `injectMutation` and `injectMutationState`.
-Optimistic update via `onMutate`, rolling back on `onError`:
-```angular-ts
-@Component({
- selector: 'todos',
- template: ``,
-})
-export class Todos {
- readonly #queryClient = inject(QueryClient)
-
- readonly addMutation = injectMutation(() => ({
- mutationFn: addTodo,
- onMutate: async (newTodo) => {
- await this.#queryClient.cancelQueries({ queryKey: ['todos'] })
- const previousTodos = this.#queryClient.getQueryData>(['todos'])
-
- this.#queryClient.setQueryData>(['todos'], (old) => [
- ...(old ?? []),
- newTodo,
- ])
-
- // Passed to `onError` as `onMutateResult` if the mutation fails.
- return { previousTodos }
- },
- onError: (_err, _newTodo, onMutateResult) => {
- this.#queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)
- },
- onSettled: () => {
- this.#queryClient.invalidateQueries({ queryKey: ['todos'] })
- },
- }))
-}
-```
+## Example
-Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a promise per
-call instead, so you can wait for all of them when they succeed:
```angular-ts
@Component({
- selector: 'todos',
template: `
-
- `,
-})
-export class Todos {
- readonly #queryClient = inject(QueryClient)
-
- readonly addMutation = injectMutation(() => ({
- mutationFn: addTodo,
- onSuccess: () => this.#queryClient.invalidateQueries({ queryKey: ['todos'] }),
- }))
-
- async handleAddAll(todos: Array) {
- try {
- await Promise.all(todos.map((todo) => this.addMutation.mutateAsync(todo)))
- } catch (error) {
- console.error('Failed to add todos:', error)
+ @if (mutation.isPending()) {
+ Saving...
+ } @else if (mutation.isError()) {
+ Error: {{ mutation.error()?.message }}
}
- }
-}
-```
-
-If some of the mutations above can fail independently of the others, and you want to know which ones did —
-rather than losing that information the moment the first one rejects — swap `Promise.all` for
-`Promise.allSettled`:
-```angular-ts
-@Component({
- selector: 'todos',
- template: `
-
+
`,
})
-export class Todos {
- readonly #queryClient = inject(QueryClient)
-
- readonly addMutation = injectMutation(() => ({
- mutationFn: addTodo,
- onSuccess: () => this.#queryClient.invalidateQueries({ queryKey: ['todos'] }),
+export class CreatePost {
+ readonly mutation = injectMutation(() => ({
+ mutationFn: createPost,
}))
-
- async handleAddAll(todos: Array) {
- const addResults = await Promise.allSettled(
- todos.map((todo) => this.addMutation.mutateAsync(todo)),
- )
-
- addResults.forEach((addResult, index) => {
- if (addResult.status === 'rejected') {
- console.error(`Failed to add "${todos[index]}":`, addResult.reason)
- }
- })
- }
}
```
diff --git a/docs/framework/angular/reference/functions/injectMutationState.md b/docs/framework/angular/reference/functions/injectMutationState.md
index 2e43406cfee..ba61d160d78 100644
--- a/docs/framework/angular/reference/functions/injectMutationState.md
+++ b/docs/framework/angular/reference/functions/injectMutationState.md
@@ -4,13 +4,12 @@ title: injectMutationState
---
```ts
-function injectMutationState(injectMutationStateFn: () => MutationStateOptions, options?: InjectMutationStateOptions): Signal;
+function injectMutationState(options: () => MutationStateOptions): Signal;
```
-Defined in: [packages/angular-query-experimental/src/inject-mutation-state.ts:106](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L106)
+Defined in: [packages/angular-query/src/inject-mutation-state.ts:55](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-mutation-state.ts#L55)
-Injects a signal that gives you access to all mutations in the `MutationCache`. You can pass `filters`
-([MutationFilters](../interfaces/MutationFilters.md)) to narrow down your mutations, and `select` to transform the mutation state.
+Injects a signal that tracks the state of all mutations.
## Type Parameters
@@ -18,71 +17,20 @@ Injects a signal that gives you access to all mutations in the `MutationCache`.
`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\>
-## Parameters
-
-### injectMutationStateFn
+### TMutation
-() => `MutationStateOptions`\<`TResult`\>
+`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\>
-A function returning the `filters` to narrow down matched mutations, and an
-optional `select` to transform the mutation state. Similar to `computed` from Angular, this function runs
-in the reactive context, so signals read inside it re-narrow the matched mutations.
+## Parameters
-### options?
+### options
-[`InjectMutationStateOptions`](../interfaces/InjectMutationStateOptions.md)
+() => [`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`, `TMutation`\>
-Additional configuration
+A function that returns mutation state options.
## Returns
`Signal`\<`TResult`[]\>
-A `Signal` with an Array of whatever `select` returns for each matching mutation.
-
-## Examples
-
-Get all variables of all running mutations:
-```angular-ts
-@Component({
- selector: 'pending-posts',
- template: `{{ pendingVariables().length }} posts saving...`,
-})
-export class PendingPosts {
- readonly pendingVariables = injectMutationState(() => ({
- filters: { status: 'pending' },
- select: (mutation) => mutation.state.variables,
- }))
-}
-```
-
-Get all data for specific mutations via the `mutationKey`:
-```angular-ts
-const mutationKey = ['posts']
-
-@Component({
- selector: 'posts',
- template: `
-
- `,
-})
-export class Posts {
- // Some mutation that we want to get the state for
- readonly createPostMutation = injectMutation(() => ({
- mutationKey,
- mutationFn: createPosts,
- }))
-
- readonly savedPosts = injectMutationState(() => ({
- // this mutation key needs to match the mutation key of the given mutation (see above)
- filters: { mutationKey, status: 'success' },
- select: (mutation) => mutation.state.data,
- }))
-
- createPost() {
- this.createPostMutation.mutate(['New Post'])
- }
-}
-```
+The signal that tracks the state of all mutations.
diff --git a/docs/framework/angular/reference/functions/injectQueries.md b/docs/framework/angular/reference/functions/injectQueries.md
new file mode 100644
index 00000000000..04d075d0f46
--- /dev/null
+++ b/docs/framework/angular/reference/functions/injectQueries.md
@@ -0,0 +1,66 @@
+---
+id: injectQueries
+title: injectQueries
+---
+
+```ts
+function injectQueries(optionsFn: () => InjectQueriesOptions): Signal;
+```
+
+Defined in: [packages/angular-query/src/inject-queries.ts:57](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-queries.ts#L57)
+
+Injects multiple queries that run in parallel and react to Angular signals.
+
+## Type Parameters
+
+### T
+
+`T` *extends* `any`[]
+
+### TCombinedResult
+
+`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GenericGetDefinedOrUndefinedQueryResult`\<`Head`, `InferDataAndError`\<`Head`\>\[`"data"`\], [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`InferDataAndError`\<`Head`\>\[`"data"`\], `InferDataAndError`\<`Head`\>\[`"error"`\]\>, [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<`InferDataAndError`\<`Head`\>\[`"data"`\], `InferDataAndError`\<`Head`\>\[`"error"`\]\>\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GenericGetDefinedOrUndefinedQueryResult`\<`Head`, `InferDataAndError`\<`Head`\>\[`"data"`\], [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`InferDataAndError`\<`Head`\>\[`"data"`\], `InferDataAndError`\<`Head`\>\[`"error"`\]\>, [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<`InferDataAndError`\<`Head`\>\[`"data"`\], `InferDataAndError`\<`Head`\>\[`"error"`\]\>\>, `GenericGetDefinedOrUndefinedQueryResult`\<`Head`, `InferDataAndError`\<`Head`\>\[`"data"`\], [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`InferDataAndError`\<`Head`\>\[`"data"`\], `InferDataAndError`\<`Head`\>\[`"error"`\]\>, [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<`InferDataAndError`\<`Head`\>\[`"data"`\], `InferDataAndError`\<`Head`\>\[`"error"`\]\>\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GenericGetDefinedOrUndefinedQueryResult`\<`Head`, ...\[...\], [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<..., ...\>, [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<..., ...\>\>, `GenericGetDefinedOrUndefinedQueryResult`\<`Head`, ...\[...\], [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<..., ...\>, [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<..., ...\>\>, `GenericGetDefinedOrUndefinedQueryResult`\<`Head`, ...\[...\], [`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<..., ...\>, [`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<..., ...\>\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GenericGetDefinedOrUndefinedQueryResult\\], InferDataAndError\<(...)\>\["data"\], CreateQueryResult\<(...)\[(...)\], (...)\[(...)\]\>, DefinedCreateQueryResult\<(...)\[(...)\], (...)\[(...)\]\>\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GenericGetDefinedOrUndefinedQueryResult\\], InferDataAndError\\]\>\["data"\], CreateQueryResult\\]\>\["data"\], InferDataAndError\\]\>\["error"\]\>, DefinedCreateQueryResult\\]\>\["data"\], InferDataAndError\\]\>\["error"\]\>\> \}
+
+## Parameters
+
+### optionsFn
+
+() => [`InjectQueriesOptions`](../interfaces/InjectQueriesOptions.md)\<`T`, `TCombinedResult`\>
+
+A function that returns the queries' options. Similar to `computed` from Angular,
+this function runs in the reactive context, so signals read inside it drive the queries.
+
+## Returns
+
+`Signal`\<`TCombinedResult`\>
+
+A signal containing the query results in the same order as the input queries.
+
+## See
+
+https://tanstack.com/query/latest/docs/framework/angular/guides/parallel-queries
+
+## Example
+
+```angular-ts
+@Component({
+ selector: 'users',
+ template: `
+ @for (query of userQueries(); track $index) {
+ @if (query.isSuccess()) {
+