Skip to content

Commit baf7313

Browse files
authored
Merge branch 'main' into fix-some-links
2 parents da1c17e + 5b6c67f commit baf7313

File tree

80 files changed

+687
-311
lines changed

Some content is hidden

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

80 files changed

+687
-311
lines changed

docs/framework/react/guides/mutations.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ try {
267267

268268
## Retry
269269

270-
By default TanStack Query will not retry a mutation on error, but it is possible with the `retry` option:
270+
By default, TanStack Query will not retry a mutation on error, but it is possible with the `retry` option:
271271

272272
[//]: # 'Example9'
273273

@@ -390,6 +390,23 @@ We also have an extensive [offline example](../../examples/offline) that covers
390390

391391
[//]: # 'Materials'
392392

393+
## Mutation Scopes
394+
395+
Per default, all mutations run in parallel - even if you invoke `.mutate()` of the same mutation multiple times. Mutations can be given a `scope` with an `id` to avoid that. All mutations with the same `scope.id` will run in serial, which means when they are triggered, they will start in `isPaused: true` state if there is already a mutation for that scope in progress. They will be put into a queue and will automatically resume once their time in the queue has come.
396+
397+
[//]: # 'ExampleScopes'
398+
399+
```tsx
400+
const mutation = useMutation({
401+
mutationFn: addTodo,
402+
scope: {
403+
id: 'todo',
404+
},
405+
})
406+
```
407+
408+
[//]: # 'ExampleScopes'
409+
393410
## Further reading
394411

395412
For more information about mutations, have a look at [#12: Mastering Mutations in React Query](../../community/tkdodos-blog#12-mastering-mutations-in-react-query) from

docs/framework/react/reference/useMutation.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
} = useMutation({
2424
mutationFn,
2525
gcTime,
26+
meta,
2627
mutationKey,
2728
networkMode,
2829
onError,
@@ -31,8 +32,8 @@ const {
3132
onSuccess,
3233
retry,
3334
retryDelay,
35+
scope,
3436
throwOnError,
35-
meta,
3637
})
3738

3839
mutate(variables, {
@@ -85,6 +86,10 @@ mutate(variables, {
8586
- This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds.
8687
- A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff.
8788
- A function like `attempt => attempt * 1000` applies linear backoff.
89+
- `scope: { id: string }`
90+
- Optional
91+
- Defaults to a unique id (so that all mutations run in parallel)
92+
- Mutations with the same scope id will run in serial
8893
- `throwOnError: undefined | boolean | (error: TError) => boolean`
8994
- Defaults to the global query config's `throwOnError` value, which is `undefined`
9095
- Set this to `true` if you want mutation errors to be thrown in the render phase and propagate to the nearest error boundary

examples/angular/basic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/platform-browser": "^17.3.3",
1818
"@angular/platform-browser-dynamic": "^17.3.3",
1919
"@angular/router": "^17.3.3",
20-
"@tanstack/angular-query-experimental": "^5.30.0",
20+
"@tanstack/angular-query-experimental": "^5.31.0",
2121
"rxjs": "^7.8.1",
2222
"tslib": "^2.6.2",
2323
"zone.js": "^0.14.4"
@@ -26,7 +26,7 @@
2626
"@angular-devkit/build-angular": "^17.3.3",
2727
"@angular/cli": "^17.3.3",
2828
"@angular/compiler-cli": "^17.3.3",
29-
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
29+
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
3030
"typescript": "5.2.2"
3131
}
3232
}

examples/angular/infinite-query-with-max-pages/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/platform-browser": "^17.3.3",
1818
"@angular/platform-browser-dynamic": "^17.3.3",
1919
"@angular/router": "^17.3.3",
20-
"@tanstack/angular-query-experimental": "^5.30.0",
20+
"@tanstack/angular-query-experimental": "^5.31.0",
2121
"rxjs": "^7.8.1",
2222
"tslib": "^2.6.2",
2323
"zone.js": "^0.14.4"
@@ -26,7 +26,7 @@
2626
"@angular-devkit/build-angular": "^17.3.3",
2727
"@angular/cli": "^17.3.3",
2828
"@angular/compiler-cli": "^17.3.3",
29-
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
29+
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
3030
"typescript": "5.2.2"
3131
}
3232
}

examples/angular/router/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/platform-browser": "^17.3.3",
1818
"@angular/platform-browser-dynamic": "^17.3.3",
1919
"@angular/router": "^17.3.3",
20-
"@tanstack/angular-query-experimental": "^5.30.0",
20+
"@tanstack/angular-query-experimental": "^5.31.0",
2121
"rxjs": "^7.8.1",
2222
"tslib": "^2.6.2",
2323
"zone.js": "^0.14.4"
@@ -26,7 +26,7 @@
2626
"@angular-devkit/build-angular": "^17.3.3",
2727
"@angular/cli": "^17.3.3",
2828
"@angular/compiler-cli": "^17.3.3",
29-
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
29+
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
3030
"typescript": "5.2.2"
3131
}
3232
}

examples/angular/simple/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/platform-browser": "^17.3.3",
1818
"@angular/platform-browser-dynamic": "^17.3.3",
1919
"@angular/router": "^17.3.3",
20-
"@tanstack/angular-query-experimental": "^5.30.0",
20+
"@tanstack/angular-query-experimental": "^5.31.0",
2121
"rxjs": "^7.8.1",
2222
"tslib": "^2.6.2",
2323
"zone.js": "^0.14.4"
@@ -26,7 +26,7 @@
2626
"@angular-devkit/build-angular": "^17.3.3",
2727
"@angular/cli": "^17.3.3",
2828
"@angular/compiler-cli": "^17.3.3",
29-
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
29+
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
3030
"typescript": "5.2.2"
3131
}
3232
}

examples/react/algolia/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"dependencies": {
1212
"@algolia/client-search": "4.22.1",
1313
"@algolia/transporter": "4.22.1",
14-
"@tanstack/react-query": "^5.29.2",
15-
"@tanstack/react-query-devtools": "^5.29.2",
14+
"@tanstack/react-query": "^5.31.0",
15+
"@tanstack/react-query-devtools": "^5.31.0",
1616
"algoliasearch": "4.22.1",
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0"

examples/react/auto-refetching/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"start": "next start"
88
},
99
"dependencies": {
10-
"@tanstack/react-query": "^5.29.2",
11-
"@tanstack/react-query-devtools": "^5.29.2",
10+
"@tanstack/react-query": "^5.31.0",
11+
"@tanstack/react-query-devtools": "^5.31.0",
1212
"axios": "^1.6.7",
1313
"isomorphic-unfetch": "4.0.2",
1414
"next": "^14.0.0",

examples/react/basic-graphql-request/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"preview": "vite preview"
99
},
1010
"dependencies": {
11-
"@tanstack/react-query": "^5.29.2",
12-
"@tanstack/react-query-devtools": "^5.29.2",
11+
"@tanstack/react-query": "^5.31.0",
12+
"@tanstack/react-query-devtools": "^5.31.0",
1313
"graphql": "^16.8.1",
1414
"graphql-request": "^6.1.0",
1515
"react": "^18.2.0",

examples/react/basic-typescript/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"test:types": "tsc"
1010
},
1111
"dependencies": {
12-
"@tanstack/query-sync-storage-persister": "^5.29.0",
13-
"@tanstack/react-query": "^5.29.2",
14-
"@tanstack/react-query-devtools": "^5.29.2",
15-
"@tanstack/react-query-persist-client": "^5.29.2",
12+
"@tanstack/query-sync-storage-persister": "^5.31.0",
13+
"@tanstack/react-query": "^5.31.0",
14+
"@tanstack/react-query-devtools": "^5.31.0",
15+
"@tanstack/react-query-persist-client": "^5.31.0",
1616
"axios": "^1.6.7",
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0"

0 commit comments

Comments
 (0)