Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cd70269
feat(angular-query-devtools): move devtools to conditional sub-paths,…
arnoud-dv Jun 11, 2025
fbc3eb0
Fix compatibility with moduleResolution node
arnoud-dv Jun 12, 2025
1088d15
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Jun 12, 2025
f8334ca
ci: apply automated fixes
autofix-ci[bot] Jun 12, 2025
59ad3d8
fix preview release for angular-query
arnoud-dv Jun 12, 2025
09986a2
Merge branch 'feature/angular-query-devtools-sub-path-imports' of git…
arnoud-dv Jun 12, 2025
e9055fb
Fix angular-query preview release
arnoud-dv Jun 12, 2025
5523975
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Jun 17, 2025
635774e
Revert some changes made obsolete by better Vite based alternative
arnoud-dv Jun 17, 2025
c2600eb
Update export paths
arnoud-dv Jun 17, 2025
d6f6fa3
Fix production exports and publishconfig
arnoud-dv Jun 17, 2025
7eb9e72
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Jul 23, 2025
891f8d6
knip config
arnoud-dv Jul 23, 2025
6b72a82
remove postpack
arnoud-dv Jul 23, 2025
4fa4b2a
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Aug 1, 2025
4637f21
Generate API reference docs
arnoud-dv Aug 1, 2025
a05c217
type declarations in correct directory
arnoud-dv Aug 1, 2025
63df240
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Aug 3, 2025
4f148eb
Update documentation
arnoud-dv Aug 4, 2025
9df1e24
knip config
arnoud-dv Aug 4, 2025
f29d11e
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Aug 8, 2025
4fbe3d2
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Sep 2, 2025
34323da
Optional core devtools dependency
arnoud-dv Sep 2, 2025
727d5df
ci: apply automated fixes
autofix-ci[bot] Sep 2, 2025
d6d621e
Merge remote-tracking branch 'upstream/main' into feature/angular-que…
arnoud-dv Sep 12, 2025
a32e4c0
regenerate api reference docs
arnoud-dv Sep 12, 2025
55b220d
ci: apply automated fixes
autofix-ci[bot] Sep 12, 2025
c18e6c2
ci: apply automated fixes (attempt 2/3)
autofix-ci[bot] Sep 12, 2025
b748f14
Merge remote-tracking branch 'origin/main' into feature/angular-query…
arnoud-dv Sep 12, 2025
73c8099
regenerate api reference docs
arnoud-dv Sep 12, 2025
51c4dce
Merge branch 'feature/angular-query-devtools-sub-path-imports' of git…
arnoud-dv Sep 12, 2025
7f8a863
formatting
arnoud-dv Sep 12, 2025
6a46c1e
apply coderabbit suggestions
arnoud-dv Sep 12, 2025
bc62387
Improve unit tests
arnoud-dv Sep 14, 2025
8813efb
docs
arnoud-dv Sep 15, 2025
1f2db27
Merge remote-tracking branch 'origin/main' into feature/angular-query…
arnoud-dv Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ comment:

component_management:
individual_components:
- component_id: angular-query-devtools-experimental
name: '@tanstack/angular-query-devtools-experimental'
paths:
- packages/angular-query-devtools-experimental/**
- component_id: angular-query-experimental
name: '@tanstack/angular-query-experimental'
paths:
Expand Down
79 changes: 61 additions & 18 deletions docs/framework/angular/devtools.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,38 @@ title: Devtools

The devtools help you debug and inspect your queries and mutations. You can enable the devtools by adding `withDevtools` to `provideTanStackQuery`.

By default, the devtools are enabled when Angular [`isDevMode`](https://angular.dev/api/core/isDevMode) returns true. So you don't need to worry about excluding them during a production build. The core tools are lazily loaded and excluded from bundled code. In most cases, all you'll need to do is add `withDevtools()` to `provideTanStackQuery` without any additional configuration.
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.

```ts
import {
QueryClient,
provideTanStackQuery,
withDevtools,
} from '@tanstack/angular-query-experimental'

import { withDevtools } from '@tanstack/angular-query-experimental/devtools'

export const appConfig: ApplicationConfig = {
providers: [provideTanStackQuery(new QueryClient(), withDevtools())],
}
```

## Configuring if devtools are loaded
## 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.

```ts
import { withDevtools } from '@tanstack/angular-query-experimental/devtools/production'
```

If you need more control over when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations. For instance, you might have a test environment running in production mode but still require devtools to be available.
To control when devtools are loaded, you can use the `loadDevtools` option.

When not setting the option or setting it to 'auto', the devtools will be loaded when Angular is in development mode.
When not setting the option or setting it to 'auto', the devtools will be loaded automatically when Angular runs in development mode.

```ts
import { withDevtools } from '@tanstack/angular-query-experimental/devtools'

provideTanStackQuery(new QueryClient(), withDevtools())

// which is equivalent to
Expand All @@ -45,10 +56,16 @@ provideTanStackQuery(

When setting the option to true, the devtools will be loaded 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'

provideTanStackQuery(
new QueryClient(),
withDevtools(() => ({ loadDevtools: true })),
withDevtools(() => ({ loadDevtools: environment.loadDevtools })),
)
```

Expand All @@ -61,44 +78,68 @@ provideTanStackQuery(
)
```

The `withDevtools` options are returned from a callback function to support reactivity through signals. In the following example
a signal is created from a RxJS observable that listens for a keyboard shortcut. When the event is triggered, the devtools are lazily loaded.
Using this technique allows you to support on-demand loading of the devtools even in production mode, without including the full tools in the bundled code.
## Derive options through reactivity

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.

> If you don't need devtools in production builds, don't use the `production` sub-path. Even though most of the devtools are lazy loaded on-demand, code is needed for on-demand loading and option handling. When importing devtools from `@tanstack/angular-query-experimental/devtools`, all devtools code will be excluded from your build and no lazy chunks will be created, minimizing deployment size.

The example below always loads devtools in development mode and loads on-demand in production mode when a keyboard shortcut is pressed.

```ts
import { Injectable, isDevMode } from '@angular/core'
import { fromEvent, map, scan } from 'rxjs'
import { toSignal } from '@angular/core/rxjs-interop'

@Injectable({ providedIn: 'root' })
class DevtoolsOptionsManager {
export class DevtoolsOptionsManager {
loadDevtools = toSignal(
fromEvent<KeyboardEvent>(document, 'keydown').pipe(
map(
(event): boolean =>
event.metaKey && event.ctrlKey && event.shiftKey && event.key === 'D',
),
scan((acc, curr) => acc || curr, false),
scan((acc, curr) => acc || curr, isDevMode()),
),
{
initialValue: false,
initialValue: isDevMode(),
},
)
}
```

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.

```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'

export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(),
provideTanStackQuery(
new QueryClient(),
withDevtools(() => ({
initialIsOpen: true,
loadDevtools: inject(DevtoolsOptionsManager).loadDevtools(),
})),
withDevtools(
(devToolsOptionsManager: DevtoolsOptionsManager) => ({
loadDevtools: devToolsOptionsManager.loadDevtools(),
}),
{
// `deps` is used to inject and pass `DevtoolsOptionsManager` to the `withDevtools` callback.
deps: [DevtoolsOptionsManager],
},
),
),
],
}
```

### Options
### Options returned from the callback

Of these options `client`, `position`, `errorTypes`, `buttonPosition`, and `initialIsOpen` support reactivity through signals.
Of these options `loadDevtools`, `client`, `position`, `errorTypes`, `buttonPosition`, and `initialIsOpen` support reactivity through signals.

- `loadDevtools?: 'auto' | boolean`
- Defaults to `auto`: lazily loads devtools when in development mode. Skips loading in production mode.
Expand All @@ -121,3 +162,5 @@ Of these options `client`, `position`, `errorTypes`, `buttonPosition`, and `init
- `shadowDOMTarget?: ShadowRoot`
- Default behavior will apply the devtool's styles to the head tag within the DOM.
- Use this to pass a shadow DOM target to the devtools so that the styles will be applied within the shadow DOM instead of within the head tag in the light DOM.
- `hideDisabledQueries?: boolean`
- Set this to true to hide disabled queries from the devtools panel.
2 changes: 1 addition & 1 deletion docs/framework/angular/guides/query-cancellation.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ query = injectQuery(() => ({

[//]: # 'Example3'

```tsx
```ts
import axios from 'axios'

const query = injectQuery(() => ({
Expand Down
48 changes: 25 additions & 23 deletions docs/framework/angular/reference/functions/infinitequeryoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: infiniteQueryOptions
title: infiniteQueryOptions
---

<!-- DO NOT EDIT: this page is autogenerated from the type comments -->

# Function: infiniteQueryOptions()

Allows to share and re-use infinite query options in a type-safe way.
Expand All @@ -24,16 +26,19 @@ function infiniteQueryOptions<
TPageParam,
>(
options,
): DefinedInitialDataInfiniteOptions<
): CreateInfiniteQueryOptions<
TQueryFnData,
TError,
TData,
TQueryKey,
TPageParam
> &
object &
object
```

Defined in: [infinite-query-options.ts:88](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L88)

Allows to share and re-use infinite query options in a type-safe way.

The `queryKey` will be tagged with the type from `queryFn`.
Expand All @@ -60,7 +65,7 @@ The infinite query options to tag with the type from `queryFn`.

### Returns

[`DefinedInitialDataInfiniteOptions`](../../type-aliases/definedinitialdatainfiniteoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object`
[`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & `object`

Comment on lines +68 to 69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Validate doc kind path for CreateInfiniteQueryOptions

The link path uses “interfaces/createinfinitequeryoptions.md”. If CreateInfiniteQueryOptions is a type alias (not an interface), the path should be under type-aliases to avoid 404s/inconsistency. Please confirm the generator’s kind mapping.

You can scan for the emitted file to confirm:

Also applies to: 131-133, 191-193


🏁 Script executed:

#!/bin/bash
# Verify whether CreateInfiniteQueryOptions is documented under interfaces or type-aliases
fd -a createinfinitequeryoptions.md docs | sed 's|^\./||'
rg -n "createinfinitequeryoptions" -g "docs/**/*.md" -n

Length of output: 2240


Update Angular docs CreateInfiniteQueryOptions path to type-aliases
Change all links in docs/framework/angular/reference from ../interfaces/createinfinitequeryoptions.md to ../type-aliases/createinfinitequeryoptions.md (in functions/infinitequeryoptions.md at lines 68, 131, 191; injectinfinitequery.md at line 175; and index.md at line 15).

🤖 Prompt for AI Agents
In docs/framework/angular/reference/functions/infinitequeryoptions.md around
lines 68-69, update the Markdown link target from
../../interfaces/createinfinitequeryoptions.md to
../../type-aliases/createinfinitequeryoptions.md; also update the same link in
docs/framework/angular/reference/functions/infinitequeryoptions.md at lines ~131
and ~191, in docs/framework/angular/reference/functions/injectinfinitequery.md
at line ~175, and in docs/framework/angular/reference/index.md at line ~15 so
all references point to ../type-aliases/createinfinitequeryoptions.md instead of
../interfaces/createinfinitequeryoptions.md.

The tagged infinite query options.

Expand All @@ -70,10 +75,6 @@ The tagged infinite query options.

The infinite query options to tag with the type from `queryFn`.

### Defined in

[infinite-query-options.ts:94](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L94)

## Call Signature

```ts
Expand All @@ -85,16 +86,22 @@ function infiniteQueryOptions<
TPageParam,
>(
options,
): UnusedSkipTokenInfiniteOptions<
TQueryFnData,
TError,
TData,
TQueryKey,
TPageParam
): OmitKeyof<
CreateInfiniteQueryOptions<
TQueryFnData,
TError,
TData,
TQueryKey,
TPageParam
>,
'queryFn'
> &
object &
object
```

Defined in: [infinite-query-options.ts:119](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L119)

Allows to share and re-use infinite query options in a type-safe way.

The `queryKey` will be tagged with the type from `queryFn`.
Expand All @@ -121,7 +128,7 @@ The infinite query options to tag with the type from `queryFn`.

### Returns

[`UnusedSkipTokenInfiniteOptions`](../../type-aliases/unusedskiptokeninfiniteoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object`
`OmitKeyof`\<[`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryFn"`\> & `object` & `object`

The tagged infinite query options.

Expand All @@ -131,10 +138,6 @@ The tagged infinite query options.

The infinite query options to tag with the type from `queryFn`.

### Defined in

[infinite-query-options.ts:126](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L126)

## Call Signature

```ts
Expand All @@ -146,16 +149,19 @@ function infiniteQueryOptions<
TPageParam,
>(
options,
): UndefinedInitialDataInfiniteOptions<
): CreateInfiniteQueryOptions<
TQueryFnData,
TError,
TData,
TQueryKey,
TPageParam
> &
object &
object
```

Defined in: [infinite-query-options.ts:150](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L150)

Allows to share and re-use infinite query options in a type-safe way.

The `queryKey` will be tagged with the type from `queryFn`.
Expand All @@ -182,7 +188,7 @@ The infinite query options to tag with the type from `queryFn`.

### Returns

[`UndefinedInitialDataInfiniteOptions`](../../type-aliases/undefinedinitialdatainfiniteoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object`
[`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & `object`

The tagged infinite query options.

Expand All @@ -191,7 +197,3 @@ The tagged infinite query options.
### Param

The infinite query options to tag with the type from `queryFn`.

### Defined in

[infinite-query-options.ts:158](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L158)
22 changes: 9 additions & 13 deletions docs/framework/angular/reference/functions/injectinfinitequery.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: injectInfiniteQuery
title: injectInfiniteQuery
---

<!-- DO NOT EDIT: this page is autogenerated from the type comments -->

# Function: injectInfiniteQuery()

Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
Expand Down Expand Up @@ -31,6 +33,8 @@ function injectInfiniteQuery<
): DefinedCreateInfiniteQueryResult<TData, TError>
```

Defined in: [inject-infinite-query.ts:41](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L41)

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"

Expand Down Expand Up @@ -76,10 +80,6 @@ A function that returns infinite query options.

Additional configuration.

### Defined in

[inject-infinite-query.ts:42](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L42)

## Call Signature

```ts
Expand All @@ -92,6 +92,8 @@ function injectInfiniteQuery<
>(injectInfiniteQueryFn, options?): CreateInfiniteQueryResult<TData, TError>
```

Defined in: [inject-infinite-query.ts:65](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L65)

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"

Expand Down Expand Up @@ -137,10 +139,6 @@ A function that returns infinite query options.

Additional configuration.

### Defined in

[inject-infinite-query.ts:67](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L67)

## Call Signature

```ts
Expand All @@ -153,6 +151,8 @@ function injectInfiniteQuery<
>(injectInfiniteQueryFn, options?): CreateInfiniteQueryResult<TData, TError>
```

Defined in: [inject-infinite-query.ts:89](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L89)

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"

Expand All @@ -172,7 +172,7 @@ Infinite queries can additively "load more" data onto an existing set of data or

#### injectInfiniteQueryFn

() => [`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `TPageParam`\>
() => [`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>

Comment on lines +175 to 176
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Validate doc kind path for CreateInfiniteQueryOptions

Link targets “interfaces/createinfinitequeryoptions.md”. Confirm actual location/kind to avoid 404s.


🏁 Script executed:

#!/bin/bash
fd -a createinfinitequeryoptions.md docs | sed 's|^\./||'
rg -n "CreateInfiniteQueryOptions" -g "docs/**/*.md" -n

Length of output: 4118


Fix broken relative link for CreateInfiniteQueryOptions
In docs/framework/angular/reference/functions/injectinfinitequery.md (at lines 175–176), update the link to the interface’s actual location under reference/interfaces:

- [`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)
+ [`CreateInfiniteQueryOptions`](../interfaces/createinfinitequeryoptions.md)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
() => [`CreateInfiniteQueryOptions`](../../interfaces/createinfinitequeryoptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>
() => [`CreateInfiniteQueryOptions`](../interfaces/createinfinitequeryoptions.md)<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`>
🤖 Prompt for AI Agents
In docs/framework/angular/reference/functions/injectinfinitequery.md around
lines 175-176, the relative link to CreateInfiniteQueryOptions is incorrect
(uses ../../interfaces/...); update the link to point to the actual interface
location under reference/interfaces by changing the path to
../interfaces/createinfinitequeryoptions.md while preserving the link label and
type parameters.

A function that returns infinite query options.

Expand All @@ -197,7 +197,3 @@ A function that returns infinite query options.
### Param

Additional configuration.

### Defined in

[inject-infinite-query.ts:92](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L92)
Loading
Loading