From 1140633178218f2ab7d65236250869105e294e71 Mon Sep 17 00:00:00 2001 From: Vlad Kovechenkov Date: Tue, 26 Aug 2025 14:28:32 +0200 Subject: [PATCH 1/7] docs: mention second parameter of cancelQueries --- docs/reference/QueryClient.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/QueryClient.md b/docs/reference/QueryClient.md index 86634c2e5d..eeecda86a7 100644 --- a/docs/reference/QueryClient.md +++ b/docs/reference/QueryClient.md @@ -409,6 +409,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) **Options** - `filters?: QueryFilters`: [Query Filters](../../framework/react/guides/filters.md#query-filters) +- `cancelOptions?: CancelOptions`: [Cancel Options](../../framework/react/guides/filters.md#query-filters) **Returns** From 669bf1fc4fd115d065ff985c2a09dbb2b45f0067 Mon Sep 17 00:00:00 2001 From: Vlad Kovechenkov Date: Tue, 26 Aug 2025 14:56:06 +0200 Subject: [PATCH 2/7] docs: describe cancel options --- docs/framework/react/guides/filters.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/framework/react/guides/filters.md b/docs/framework/react/guides/filters.md index e290c430f5..93d8f605c6 100644 --- a/docs/framework/react/guides/filters.md +++ b/docs/framework/react/guides/filters.md @@ -71,6 +71,29 @@ A mutation filter object supports the following properties: - `predicate?: (mutation: Mutation) => boolean` - This predicate function will be used as a final filter on all matching mutations. If no other filters are specified, this function will be evaluated against every mutation in the cache. +## `Cancel Options` + +Cancel options are used to control the behavior of query cancellation operations. + +// Cancel all queries silently (no CancelledError thrown) +await queryClient.cancelQueries(undefined, { silent: true }) + +// Cancel specific queries with revert option +await queryClient.cancelQueries( + { queryKey: ['posts'] }, + { revert: true, silent: true } +) + +A cancel options object supports the following properties: + +- `silent?: boolean` + - When set to `true`, prevents `CancelledError` from being thrown during query cancellation. + - Defaults to `false` + - Useful when you want to cancel queries without handling cancellation errors. +- `revert?: boolean` + - When set to `true`, reverts the query to its previous state before cancellation. + - Defaults to `true` + ## Utils ### `matchQuery` From 6f3b60dd9f3f5ad6e5ad58f180b6807f86da62c2 Mon Sep 17 00:00:00 2001 From: Vlad Kovechenkov Date: Tue, 26 Aug 2025 14:57:04 +0200 Subject: [PATCH 3/7] docs: update link to cancel options --- docs/reference/QueryClient.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/QueryClient.md b/docs/reference/QueryClient.md index eeecda86a7..543bfe7d98 100644 --- a/docs/reference/QueryClient.md +++ b/docs/reference/QueryClient.md @@ -409,7 +409,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) **Options** - `filters?: QueryFilters`: [Query Filters](../../framework/react/guides/filters.md#query-filters) -- `cancelOptions?: CancelOptions`: [Cancel Options](../../framework/react/guides/filters.md#query-filters) +- `cancelOptions?: CancelOptions`: [Cancel Options](../../framework/react/guides/filters.md#cancel-options) **Returns** From d3bbe4f56a4a68ce6b042b10beb8c7abfbe9ca4d Mon Sep 17 00:00:00 2001 From: Vlad Kovechenkov Date: Tue, 26 Aug 2025 14:59:53 +0200 Subject: [PATCH 4/7] docs: simplify wording a bit --- docs/framework/react/guides/filters.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/framework/react/guides/filters.md b/docs/framework/react/guides/filters.md index 93d8f605c6..182f14ff23 100644 --- a/docs/framework/react/guides/filters.md +++ b/docs/framework/react/guides/filters.md @@ -75,21 +75,19 @@ A mutation filter object supports the following properties: Cancel options are used to control the behavior of query cancellation operations. -// Cancel all queries silently (no CancelledError thrown) -await queryClient.cancelQueries(undefined, { silent: true }) - -// Cancel specific queries with revert option +```tsx +// Cancel specific queries silently await queryClient.cancelQueries( { queryKey: ['posts'] }, - { revert: true, silent: true } + { silent: true } ) +``` A cancel options object supports the following properties: - `silent?: boolean` - When set to `true`, prevents `CancelledError` from being thrown during query cancellation. - Defaults to `false` - - Useful when you want to cancel queries without handling cancellation errors. - `revert?: boolean` - When set to `true`, reverts the query to its previous state before cancellation. - Defaults to `true` From cc1d561102fbdc435d02da33ec728f8ae125b0dd Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 30 Aug 2025 05:49:07 +0000 Subject: [PATCH 5/7] ci: apply automated fixes --- docs/framework/react/guides/filters.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/framework/react/guides/filters.md b/docs/framework/react/guides/filters.md index 182f14ff23..526dba9901 100644 --- a/docs/framework/react/guides/filters.md +++ b/docs/framework/react/guides/filters.md @@ -77,10 +77,7 @@ Cancel options are used to control the behavior of query cancellation operations ```tsx // Cancel specific queries silently -await queryClient.cancelQueries( - { queryKey: ['posts'] }, - { silent: true } -) +await queryClient.cancelQueries({ queryKey: ['posts'] }, { silent: true }) ``` A cancel options object supports the following properties: From 59b4b9fd903af9a7465161e1bdd5c804e2678427 Mon Sep 17 00:00:00 2001 From: Vlad Kovechenkov Date: Mon, 1 Sep 2025 14:35:16 +0200 Subject: [PATCH 6/7] docs: move cancel options info to query-cancellation guide --- docs/framework/react/guides/filters.md | 18 ------------------ .../react/guides/query-cancellation.md | 18 ++++++++++++++++++ docs/reference/QueryClient.md | 7 +++++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/framework/react/guides/filters.md b/docs/framework/react/guides/filters.md index 526dba9901..e290c430f5 100644 --- a/docs/framework/react/guides/filters.md +++ b/docs/framework/react/guides/filters.md @@ -71,24 +71,6 @@ A mutation filter object supports the following properties: - `predicate?: (mutation: Mutation) => boolean` - This predicate function will be used as a final filter on all matching mutations. If no other filters are specified, this function will be evaluated against every mutation in the cache. -## `Cancel Options` - -Cancel options are used to control the behavior of query cancellation operations. - -```tsx -// Cancel specific queries silently -await queryClient.cancelQueries({ queryKey: ['posts'] }, { silent: true }) -``` - -A cancel options object supports the following properties: - -- `silent?: boolean` - - When set to `true`, prevents `CancelledError` from being thrown during query cancellation. - - Defaults to `false` -- `revert?: boolean` - - When set to `true`, reverts the query to its previous state before cancellation. - - Defaults to `true` - ## Utils ### `matchQuery` diff --git a/docs/framework/react/guides/query-cancellation.md b/docs/framework/react/guides/query-cancellation.md index 528262336b..1d34c13492 100644 --- a/docs/framework/react/guides/query-cancellation.md +++ b/docs/framework/react/guides/query-cancellation.md @@ -188,6 +188,24 @@ return ( [//]: # 'Example7' +## `Cancel Options` + +Cancel options are used to control the behavior of query cancellation operations. + +```tsx +// Cancel specific queries silently +await queryClient.cancelQueries({ queryKey: ['posts'] }, { silent: true }) +``` + +A cancel options object supports the following properties: + +- `silent?: boolean` + - When set to `true`, suppresses propagation of `CancelledError` to observers (e.g., `onError` callbacks) and related notifications, and returns the retry promise instead of rejecting. + - Defaults to `false` +- `revert?: boolean` + - When set to `true`, restores the query’s state (data and status) from immediately before the in-flight fetch, sets `fetchStatus` back to `idle`, and only throws if there was no prior data. + - Defaults to `true` + ## Limitations Cancellation does not work when working with `Suspense` hooks: `useSuspenseQuery`, `useSuspenseQueries` and `useSuspenseInfiniteQuery`. diff --git a/docs/reference/QueryClient.md b/docs/reference/QueryClient.md index 543bfe7d98..ba6643df32 100644 --- a/docs/reference/QueryClient.md +++ b/docs/reference/QueryClient.md @@ -403,13 +403,16 @@ The `cancelQueries` method can be used to cancel outgoing queries based on their This is most useful when performing optimistic updates since you will likely need to cancel any outgoing query refetches so they don't clobber your optimistic update when they resolve. ```tsx -await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +await queryClient.cancelQueries( + { queryKey: ['posts'], exact: true }, + { silent: true } +) ``` **Options** - `filters?: QueryFilters`: [Query Filters](../../framework/react/guides/filters.md#query-filters) -- `cancelOptions?: CancelOptions`: [Cancel Options](../../framework/react/guides/filters.md#cancel-options) +- `cancelOptions?: CancelOptions`: [Cancel Options](../../framework/react/guides/query-cancellation.md#cancel-options) **Returns** From b913dbe42dd3f19c5dce0d37f7cf5d18663b812d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 02:35:10 +0000 Subject: [PATCH 7/7] ci: apply automated fixes --- docs/reference/QueryClient.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/QueryClient.md b/docs/reference/QueryClient.md index ba6643df32..a6e57679e2 100644 --- a/docs/reference/QueryClient.md +++ b/docs/reference/QueryClient.md @@ -405,7 +405,7 @@ This is most useful when performing optimistic updates since you will likely nee ```tsx await queryClient.cancelQueries( { queryKey: ['posts'], exact: true }, - { silent: true } + { silent: true }, ) ```