Skip to content

Commit 49addbc

Browse files
committed
merged with latest
2 parents 04ac1dd + d51a9dc commit 49addbc

File tree

242 files changed

+3825
-3020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+3825
-3020
lines changed

.github/workflows/pr.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ jobs:
6969
Sizes for commit ${{ env.COMMIT_SHA }}:
7070
| Branch | Bundle Size |
7171
|--------|--------|
72-
| Main | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.0.0/jsx-runtime?target=es2022%22,%22react@^19.0.0?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.0.0/jsx-runtime?target=es2022%22,%22react@%5E19.0.0?target=es2022%22%5D%7D%7D) |
73-
| This PR | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.0.0/jsx-runtime?target=es2022%22,%22react@^19.0.0?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.0.0/jsx-runtime?target=es2022%22,%22react@%5E19.0.0?target=es2022%22%5D%7D%7D) |
72+
| Main | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.1.0/jsx-runtime?target=es2022%22,%22react@^19.1.0?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.1.0/jsx-runtime?target=es2022%22,%22react@%5E19.1.0?target=es2022%22%5D%7D%7D) |
73+
| This PR | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.1.0/jsx-runtime?target=es2022%22,%22react@^19.1.0?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.1.0/jsx-runtime?target=es2022%22,%22react@%5E19.1.0?target=es2022%22%5D%7D%7D) |
7474
continue-on-error: true

.prettierignore

-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@
88
pnpm-lock.yaml
99
packages/**/tsup.config.bundled*.mjs
1010
**/tsconfig.vitest-temp.json
11-
12-
# API Extractor report
13-
packages/angular-query-experimental/etc/*.md

docs/framework/angular/guides/caching.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: caching
33
title: Caching Examples
44
---
55

6-
> Please thoroughly read the [Important Defaults](../important-defaults) before reading this guide
6+
> Please thoroughly read the [Important Defaults](./important-defaults.md) before reading this guide
77
88
## Basic Example
99

@@ -23,7 +23,7 @@ Let's assume we are using the default `gcTime` of **5 minutes** and the default
2323
- A second instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` initializes elsewhere.
2424
- Since the cache already has data for the `['todos']` key from the first query, that data is immediately returned from the cache.
2525
- The new instance triggers a new network request using its query function.
26-
- Note that regardless of whether both `fetchTodos` query functions are identical or not, both queries' [`status`](../../reference/injectQuery) are updated (including `isFetching`, `isPending`, and other related values) because they have the same query key.
26+
- Note that regardless of whether both `fetchTodos` query functions are identical or not, both queries' [`status`](../../reference/injectQuery.md) are updated (including `isFetching`, `isPending`, and other related values) because they have the same query key.
2727
- When the request completes successfully, the cache's data under the `['todos']` key is updated with the new data, and both instances are updated with the new data.
2828
- Both instances of the `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` query are destroyed and no longer in use.
2929
- Since there are no more active instances of this query, a garbage collection timeout is set using `gcTime` to delete and garbage collect the query (defaults to **5 minutes**).

docs/framework/angular/guides/invalidations-from-mutations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ export class TodosComponent {
3838

3939
[//]: # 'Example2'
4040

41-
You can wire up your invalidations to happen using any of the callbacks available in the [`injectMutation` function](../mutations)
41+
You can wire up your invalidations to happen using any of the callbacks available in the [`injectMutation` function](../mutations.md)

docs/framework/angular/guides/mutation-options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Mutation Options
55

66
One of the best ways to share mutation options between multiple places,
77
is to use the `mutationOptions` helper. At runtime, this helper just returns whatever you pass into it,
8-
but it has a lot of advantages when using it [with TypeScript](../../typescript#typing-query-options).
8+
but it has a lot of advantages when using it [with TypeScript](../../typescript#typing-query-options.md).
99
You can define all possible options for a mutation in one place,
1010
and you'll also get type inference and type safety for all of them.
1111

docs/framework/angular/overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ interface Response {
110110

111111
## You talked me into it, so what now?
112112

113-
- Learn TanStack Query at your own pace with our amazingly thorough [Walkthrough Guide](../installation) and [API Reference](../reference/functions/injectquery)
113+
- Learn TanStack Query at your own pace with our amazingly thorough [Walkthrough Guide](../installation.md) and [API Reference](../reference/functions/injectquery.md)

docs/framework/react/reference/useSuspenseInfiniteQuery.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Same object as [useInfiniteQuery](../reference/useInfiniteQuery.md), except that
2222

2323
- `data` is guaranteed to be defined
2424
- `isPlaceholderData` is missing
25-
- `status` is always `success`
25+
- `status` is either `success` or `error`
2626
- the derived flags are set accordingly.
2727

2828
**Caveat**

docs/framework/react/reference/useSuspenseQueries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Same structure as [useQueries](../reference/useQueries.md), except that for each
2222

2323
- `data` is guaranteed to be defined
2424
- `isPlaceholderData` is missing
25-
- `status` is always `success`
25+
- `status` is either `success` or `error`
2626
- the derived flags are set accordingly.
2727

2828
**Caveats**

docs/framework/react/reference/useSuspenseQuery.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Same object as [useQuery](../reference/useQuery.md), except that:
2121

2222
- `data` is guaranteed to be defined
2323
- `isPlaceholderData` is missing
24-
- `status` is always `success`
24+
- `status` is either `success` or `error`
2525
- the derived flags are set accordingly.
2626

2727
**Caveat**

examples/angular/auto-refetching/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.72.3",
17+
"@tanstack/angular-query-experimental": "^5.74.3",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"
@@ -23,6 +23,6 @@
2323
"@angular/build": "^19.2.5",
2424
"@angular/cli": "^19.2.5",
2525
"@angular/compiler-cli": "^19.2.4",
26-
"typescript": "5.8.2"
26+
"typescript": "5.8.3"
2727
}
2828
}

examples/angular/auto-refetching/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"sourceMap": true,
1515
"declaration": false,
1616
"experimentalDecorators": true,
17-
"moduleResolution": "bundler",
17+
"moduleResolution": "Bundler",
1818
"importHelpers": true,
1919
"target": "ES2022",
2020
"module": "ES2022",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Node.js",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:22"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @ts-check
2+
3+
/** @type {import('eslint').Linter.Config} */
4+
const config = {}
5+
6+
module.exports = config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# TanStack Query Angular basic persister example
2+
3+
To run this example:
4+
5+
- `npm install` or `yarn` or `pnpm i` or `bun i`
6+
- `npm run start` or `yarn start` or `pnpm start` or `bun start`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"cli": {
5+
"packageManager": "pnpm",
6+
"analytics": false,
7+
"cache": {
8+
"enabled": false
9+
}
10+
},
11+
"newProjectRoot": "projects",
12+
"projects": {
13+
"basic-persister": {
14+
"projectType": "application",
15+
"schematics": {
16+
"@schematics/angular:component": {
17+
"inlineTemplate": true,
18+
"inlineStyle": true,
19+
"skipTests": true
20+
},
21+
"@schematics/angular:class": {
22+
"skipTests": true
23+
},
24+
"@schematics/angular:directive": {
25+
"skipTests": true
26+
},
27+
"@schematics/angular:guard": {
28+
"skipTests": true
29+
},
30+
"@schematics/angular:interceptor": {
31+
"skipTests": true
32+
},
33+
"@schematics/angular:pipe": {
34+
"skipTests": true
35+
},
36+
"@schematics/angular:resolver": {
37+
"skipTests": true
38+
},
39+
"@schematics/angular:service": {
40+
"skipTests": true
41+
}
42+
},
43+
"root": "",
44+
"sourceRoot": "src",
45+
"prefix": "app",
46+
"architect": {
47+
"build": {
48+
"builder": "@angular/build:application",
49+
"options": {
50+
"outputPath": "dist/basic-persister",
51+
"index": "src/index.html",
52+
"browser": "src/main.ts",
53+
"polyfills": ["zone.js"],
54+
"tsConfig": "tsconfig.app.json",
55+
"assets": ["src/favicon.ico", "src/assets"],
56+
"styles": [],
57+
"scripts": []
58+
},
59+
"configurations": {
60+
"production": {
61+
"budgets": [
62+
{
63+
"type": "initial",
64+
"maximumWarning": "500kb",
65+
"maximumError": "1mb"
66+
},
67+
{
68+
"type": "anyComponentStyle",
69+
"maximumWarning": "2kb",
70+
"maximumError": "4kb"
71+
}
72+
],
73+
"outputHashing": "all"
74+
},
75+
"development": {
76+
"optimization": false,
77+
"extractLicenses": false,
78+
"sourceMap": true
79+
}
80+
},
81+
"defaultConfiguration": "production"
82+
},
83+
"serve": {
84+
"builder": "@angular/build:dev-server",
85+
"configurations": {
86+
"production": {
87+
"buildTarget": "basic-persister:build:production"
88+
},
89+
"development": {
90+
"buildTarget": "basic-persister:build:development"
91+
}
92+
},
93+
"defaultConfiguration": "development"
94+
},
95+
"extract-i18n": {
96+
"builder": "@angular/build:extract-i18n",
97+
"options": {
98+
"buildTarget": "basic-persister:build"
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@tanstack/query-example-angular-basic-persister",
3+
"type": "module",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development"
9+
},
10+
"private": true,
11+
"dependencies": {
12+
"@angular/common": "^19.2.4",
13+
"@angular/compiler": "^19.2.4",
14+
"@angular/core": "^19.2.4",
15+
"@angular/platform-browser": "^19.2.4",
16+
"@angular/platform-browser-dynamic": "^19.2.4",
17+
"@tanstack/angular-query-experimental": "^5.74.3",
18+
"@tanstack/angular-query-persist-client": "^5.62.7",
19+
"@tanstack/query-sync-storage-persister": "^5.74.3",
20+
"rxjs": "^7.8.2",
21+
"tslib": "^2.8.1",
22+
"zone.js": "^0.15.0"
23+
},
24+
"devDependencies": {
25+
"@angular/build": "^19.2.5",
26+
"@angular/cli": "^19.2.5",
27+
"@angular/compiler-cli": "^19.2.4",
28+
"typescript": "5.8.3"
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p>
2+
Try to mock offline behavior with the button in the devtools. You can navigate
3+
around as long as there is already data in the cache. You'll get a refetch as
4+
soon as you go "online" again.
5+
</p>
6+
@if (postId() > -1) {
7+
<post [postId]="postId()" (setPostId)="postId.set($event)"></post>
8+
} @else {
9+
<posts (setPostId)="postId.set($event)" />
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ChangeDetectionStrategy, Component, signal } from '@angular/core'
2+
import { PostComponent } from './components/post.component'
3+
import { PostsComponent } from './components/posts.component'
4+
5+
@Component({
6+
changeDetection: ChangeDetectionStrategy.OnPush,
7+
selector: 'basic-example',
8+
templateUrl: './app.component.html',
9+
imports: [PostComponent, PostsComponent],
10+
})
11+
export class BasicExampleComponent {
12+
postId = signal(-1)
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { provideHttpClient, withFetch } from '@angular/common/http'
2+
import {
3+
QueryClient,
4+
provideTanStackQuery,
5+
withDevtools,
6+
} from '@tanstack/angular-query-experimental'
7+
import { withPersistQueryClient } from '@tanstack/angular-query-persist-client'
8+
import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'
9+
import type { ApplicationConfig } from '@angular/core'
10+
11+
const localStoragePersister = createSyncStoragePersister({
12+
storage: window.localStorage,
13+
})
14+
15+
export const appConfig: ApplicationConfig = {
16+
providers: [
17+
provideHttpClient(withFetch()),
18+
provideTanStackQuery(
19+
new QueryClient({
20+
defaultOptions: {
21+
queries: {
22+
staleTime: 1000 * 60, // 1 minute
23+
gcTime: 1000 * 60 * 60 * 24, // 24 hours
24+
},
25+
},
26+
}),
27+
withDevtools(),
28+
withPersistQueryClient({
29+
persistOptions: {
30+
persister: localStoragePersister,
31+
},
32+
}),
33+
),
34+
],
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div>
2+
<div>
3+
<a (click)="setPostId.emit(-1)" href="#"> Back </a>
4+
</div>
5+
@if (postQuery.isPending()) {
6+
Loading...
7+
} @else if (postQuery.isError()) {
8+
Error: {{ postQuery.error().message }}
9+
}
10+
@if (postQuery.data(); as post) {
11+
<h1>{{ post.title }}</h1>
12+
<div>
13+
<p>{{ post.body }}</p>
14+
</div>
15+
@if (postQuery.isFetching()) {
16+
Background Updating...
17+
}
18+
}
19+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
EventEmitter,
5+
Output,
6+
inject,
7+
input,
8+
} from '@angular/core'
9+
import { QueryClient, injectQuery } from '@tanstack/angular-query-experimental'
10+
import { fromEvent, lastValueFrom, takeUntil } from 'rxjs'
11+
import { PostsService } from '../services/posts-service'
12+
13+
@Component({
14+
changeDetection: ChangeDetectionStrategy.OnPush,
15+
selector: 'post',
16+
standalone: true,
17+
templateUrl: './post.component.html',
18+
})
19+
export class PostComponent {
20+
#postsService = inject(PostsService)
21+
22+
@Output() setPostId = new EventEmitter<number>()
23+
24+
postId = input(0)
25+
26+
postQuery = injectQuery(() => ({
27+
enabled: this.postId() > 0,
28+
queryKey: ['post', this.postId()],
29+
queryFn: async (context) => {
30+
// Cancels the request when component is destroyed before the request finishes
31+
const abort$ = fromEvent(context.signal, 'abort')
32+
return lastValueFrom(
33+
this.#postsService.postById$(this.postId()).pipe(takeUntil(abort$)),
34+
)
35+
},
36+
}))
37+
38+
queryClient = inject(QueryClient)
39+
}

0 commit comments

Comments
 (0)