From b12badda455f091d8258f4a157379da70d83c0b7 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Sat, 3 Oct 2026 22:07:41 +0900 Subject: [PATCH 1/4] chore(*): update '@tanstack/typedoc-config' to v0.3.4 and load its custom settings plugin by package export --- package.json | 2 +- pnpm-lock.yaml | 60 ++++++++++++++++++++-------------------- scripts/generate-docs.ts | 6 ++-- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 8c7ec5fbdd9..5428128dbb7 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@cspell/eslint-plugin": "^9.2.1", "@size-limit/preset-small-lib": "^14.0.0", "@tanstack/eslint-config": "0.3.2", - "@tanstack/typedoc-config": "0.3.1", + "@tanstack/typedoc-config": "0.3.4", "@testing-library/jest-dom": "^6.8.0", "@types/node": "^22.15.3", "@vitest/coverage-istanbul": "4.1.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 486c5a72f55..c51882de1f8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -291,8 +291,8 @@ importers: specifier: 0.3.2 version: 0.3.2(@typescript-eslint/utils@8.58.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3) '@tanstack/typedoc-config': - specifier: 0.3.1 - version: 0.3.1(typescript@6.0.3) + specifier: 0.3.4 + version: 0.3.4(typescript@6.0.3) '@testing-library/jest-dom': specifier: ^6.8.0 version: 6.9.1 @@ -8356,8 +8356,8 @@ packages: '@tanstack/store@0.11.1': resolution: {integrity: sha512-mzTOBhypOuDJAy/D8n2MfUZ1HFkXnmSETviRyhqEC8LUE7/IZQExOTxMANj3KjTofYTkFNpBY67qaVrT41YccA==} - '@tanstack/typedoc-config@0.3.1': - resolution: {integrity: sha512-frgA1vjzxbdU5/xn/Z/UqyOd1yuegEfAnx9QNbcX+1XQ3TCzD+x89cMZH9iyxdTC1Tasx2gq7DCNCvX962X9WA==} + '@tanstack/typedoc-config@0.3.4': + resolution: {integrity: sha512-WXJavpiNqumNwdBQTM3wBqbHaULgoZ3cIri7xJinKqX/mOGXgc6ZghfAardD2PydP8tOcPf+xhrd1Qk/am9DMg==} engines: {node: '>=18'} '@testing-library/angular@18.1.1': @@ -13063,8 +13063,8 @@ packages: resolution: {integrity: sha512-cNOjgCnLB+FnvWWtyRTzmB3POJ+cXxTA81LoW7u8JdmhfXzriropYwpjShnz1QLLWsQwY7nIxoDmcPTwphDK9w==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - linkify-it@5.0.0: - resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} + linkify-it@5.0.2: + resolution: {integrity: sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==} listhen@1.9.0: resolution: {integrity: sha512-I8oW2+QL5KJo8zXNWX046M134WchxsXC7SawLPvRQpogCbkyQIaFxPE89A2HiwR7vAK2Dm2ERBAmyjTYGYEpBg==} @@ -13232,8 +13232,8 @@ packages: resolution: {integrity: sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==} engines: {node: '>=0.10.0'} - markdown-it@14.1.1: - resolution: {integrity: sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==} + markdown-it@14.3.2: + resolution: {integrity: sha512-sHHjZ5fJKlgrG4qns2YwVcdNep35h5fERrfkD2YNsb9UFk0UIHarbiTaHKVMlPuWAoiilyK8Fv/jAm11slsY7Q==} hasBin: true markdown-link-extractor@4.0.4: @@ -16224,23 +16224,23 @@ packages: typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} - typedoc-plugin-frontmatter@1.3.0: - resolution: {integrity: sha512-xYQFMAecMlsRUjmf9oM/Sq2FVz4zlgcbIeVFNLdO118CHTN06gIKJNSlyExh9+Xl8sK0YhIvoQwViUURxritWA==} + typedoc-plugin-frontmatter@1.3.1: + resolution: {integrity: sha512-wXKnhpiOuG3lY9GGKiKcXNrhKbPYm/jA5wbzGE/kKdwlSu8++ZbEuKA0K2dvIna3F+5EQrv+3AeObHkS1QP7JA==} peerDependencies: - typedoc-plugin-markdown: '>=4.5.0' + typedoc-plugin-markdown: '>=4.9.0' - typedoc-plugin-markdown@4.9.0: - resolution: {integrity: sha512-9Uu4WR9L7ZBgAl60N/h+jqmPxxvnC9nQAlnnO/OujtG2ubjnKTVUFY1XDhcMY+pCqlX3N2HsQM2QTYZIU9tJuw==} + typedoc-plugin-markdown@4.12.0: + resolution: {integrity: sha512-eJDEMAfxCmede22c/Jw7d0FA13ggAQv+KkwQYKYCdqI02cin6Rc9QRwbG/7XvvHWinuFejySnZVUWDtvGk3Vbg==} engines: {node: '>= 18'} peerDependencies: typedoc: 0.28.x - typedoc@0.28.14: - resolution: {integrity: sha512-ftJYPvpVfQvFzpkoSfHLkJybdA/geDJ8BGQt/ZnkkhnBYoYW6lBgPQXu6vqLxO4X75dA55hX8Af847H5KXlEFA==} + typedoc@0.28.20: + resolution: {integrity: sha512-uSKqkh8Cr48vllnEy+jdaAgOeR6Y+QCBW7usgUsKj7gJEfR7stw9U/fE49LBnj2tPRKPY0c0EBJSWe9Appmplg==} engines: {node: '>= 18', pnpm: '>= 10'} hasBin: true peerDependencies: - typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x + typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x || 6.0.x typesafe-path@0.2.2: resolution: {integrity: sha512-OJabfkAg1WLZSqJAJ0Z6Sdt3utnbzr/jh+NAHoyWHJe8CMSy79Gm085094M9nvTPy22KzTVn5Zq5mbapCI/hPA==} @@ -22609,11 +22609,11 @@ snapshots: '@tanstack/store@0.11.1': {} - '@tanstack/typedoc-config@0.3.1(typescript@6.0.3)': + '@tanstack/typedoc-config@0.3.4(typescript@6.0.3)': dependencies: - typedoc: 0.28.14(typescript@6.0.3) - typedoc-plugin-frontmatter: 1.3.0(typedoc-plugin-markdown@4.9.0(typedoc@0.28.14(typescript@6.0.3))) - typedoc-plugin-markdown: 4.9.0(typedoc@0.28.14(typescript@6.0.3)) + typedoc: 0.28.20(typescript@6.0.3) + typedoc-plugin-frontmatter: 1.3.1(typedoc-plugin-markdown@4.12.0(typedoc@0.28.20(typescript@6.0.3))) + typedoc-plugin-markdown: 4.12.0(typedoc@0.28.20(typescript@6.0.3)) transitivePeerDependencies: - typescript @@ -28455,7 +28455,7 @@ snapshots: lines-and-columns@2.0.3: {} - linkify-it@5.0.0: + linkify-it@5.0.2: dependencies: uc.micro: 2.1.0 @@ -28687,11 +28687,11 @@ snapshots: dependencies: object-visit: 1.0.1 - markdown-it@14.1.1: + markdown-it@14.3.2: dependencies: argparse: 2.0.1 entities: 4.5.0 - linkify-it: 5.0.0 + linkify-it: 5.0.2 mdurl: 2.0.0 punycode.js: 2.3.1 uc.micro: 2.1.0 @@ -32736,21 +32736,21 @@ snapshots: typedarray@0.0.6: {} - typedoc-plugin-frontmatter@1.3.0(typedoc-plugin-markdown@4.9.0(typedoc@0.28.14(typescript@6.0.3))): + typedoc-plugin-frontmatter@1.3.1(typedoc-plugin-markdown@4.12.0(typedoc@0.28.20(typescript@6.0.3))): dependencies: - typedoc-plugin-markdown: 4.9.0(typedoc@0.28.14(typescript@6.0.3)) + typedoc-plugin-markdown: 4.12.0(typedoc@0.28.20(typescript@6.0.3)) yaml: 2.9.1 - typedoc-plugin-markdown@4.9.0(typedoc@0.28.14(typescript@6.0.3)): + typedoc-plugin-markdown@4.12.0(typedoc@0.28.20(typescript@6.0.3)): dependencies: - typedoc: 0.28.14(typescript@6.0.3) + typedoc: 0.28.20(typescript@6.0.3) - typedoc@0.28.14(typescript@6.0.3): + typedoc@0.28.20(typescript@6.0.3): dependencies: '@gerrit0/mini-shiki': 3.23.0 lunr: 2.3.9 - markdown-it: 14.1.1 - minimatch: 9.0.9 + markdown-it: 14.3.2 + minimatch: 10.2.5 typescript: 6.0.3 yaml: 2.9.1 diff --git a/scripts/generate-docs.ts b/scripts/generate-docs.ts index b111f5b7e7f..fd5978bb016 100644 --- a/scripts/generate-docs.ts +++ b/scripts/generate-docs.ts @@ -1,13 +1,12 @@ import { mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises' import { createRequire } from 'node:module' -import { dirname, resolve } from 'node:path' +import { resolve } from 'node:path' import { fileURLToPath } from 'node:url' const __dirname = fileURLToPath(new URL('.', import.meta.url)) const require = createRequire(import.meta.url) const typedocConfigPackageJson = require.resolve('@tanstack/typedoc-config/package.json') -const typedocConfigDir = dirname(typedocConfigPackageJson) const typedocConfigRequire = createRequire(typedocConfigPackageJson) const TypeDoc = await import(typedocConfigRequire.resolve('typedoc')) @@ -146,7 +145,7 @@ async function generatePackageReferenceDocs(pkg: PackageReferenceDocsConfig) { plugin: [ 'typedoc-plugin-markdown', 'typedoc-plugin-frontmatter', - resolve(typedocConfigDir, './src/typedoc-custom-settings.js'), + '@tanstack/typedoc-config/typedoc-custom-settings', ], hideGenerator: true, readme: 'none', @@ -175,6 +174,7 @@ async function generatePackageReferenceDocs(pkg: PackageReferenceDocsConfig) { sourceLinkTemplate: 'https://github.com/TanStack/query/blob/{gitRevision}/{path}#L{line}', gitRevision: 'main', + displayBasePath: resolve(__dirname, '..'), entryPoints: pkg.entryPoints, tsconfig: pkg.tsconfig, ...(pkg.exclude && { exclude: pkg.exclude }), From 664aade265a64d9cc98b071a99bc3a85d8a0c56f Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Sat, 3 Oct 2026 22:07:41 +0900 Subject: [PATCH 2/4] docs(framework/*/reference): regenerate reference docs with '@tanstack/typedoc-config' v0.3.4 --- .../reference/classes/CancelledError.md | 8 +-- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../reference/classes/MutationCache.md | 16 ++--- .../reference/classes/MutationObserver.md | 8 +-- .../reference/classes/QueriesObserver.md | 10 +-- .../angular/reference/classes/Query.md | 6 +- .../angular/reference/classes/QueryCache.md | 16 ++--- .../angular/reference/classes/QueryClient.md | 7 +- .../reference/classes/QueryObserver.md | 38 ++++++++--- .../angular/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../functions/injectMutationState.md | 4 +- .../reference/functions/injectQueryClient.md | 4 +- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/provideQueryClient.md | 5 +- .../functions/provideTanStackQuery.md | 5 +- .../reference/functions/shouldThrowError.md | 2 +- .../interfaces/BaseMutationNarrowing.md | 8 +-- .../interfaces/BaseQueryNarrowing.md | 6 +- .../reference/interfaces/CancelOptions.md | 4 +- .../interfaces/CreateBaseQueryOptions.md | 54 +++++++-------- .../interfaces/CreateInfiniteQueryOptions.md | 58 ++++++++-------- .../interfaces/CreateMutationOptions.md | 26 ++++---- .../interfaces/CreateQueryOptions.md | 52 +++++++-------- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../interfaces/InjectInfiniteQueryOptions.md | 2 +- .../interfaces/InjectIsFetchingOptions.md | 2 +- .../interfaces/InjectIsMutatingOptions.md | 2 +- .../interfaces/InjectMutationOptions.md | 2 +- .../interfaces/InjectMutationStateOptions.md | 2 +- .../interfaces/InjectQueryOptions.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../reference/interfaces/MutationOptions.md | 24 +++---- .../reference/interfaces/MutationState.md | 18 ++--- .../reference/interfaces/NotifyEvent.md | 2 +- .../reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../reference/interfaces/QueryFeature.md | 4 +- .../reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../reference/interfaces/QueryOptions.md | 28 ++++---- .../reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../reference/interfaces/ResetOptions.md | 4 +- .../reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../reference/type-aliases/AnyDataTag.md | 4 +- .../DefinedInitialDataInfiniteOptions.md | 2 +- .../type-aliases/DefinedInitialDataOptions.md | 4 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../UndefinedInitialDataInfiniteOptions.md | 2 +- .../UndefinedInitialDataOptions.md | 2 +- .../UnusedSkipTokenInfiniteOptions.md | 2 +- .../type-aliases/UnusedSkipTokenOptions.md | 2 +- .../angular/reference/type-aliases/Updater.md | 2 +- .../reference/variables/environmentManager.md | 2 +- .../reference/variables/notifyManager.md | 12 ++-- .../lit/reference/classes/CancelledError.md | 4 +- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../lit/reference/classes/MutationCache.md | 16 ++--- .../lit/reference/classes/MutationObserver.md | 8 +-- .../lit/reference/classes/QueriesObserver.md | 10 +-- docs/framework/lit/reference/classes/Query.md | 6 +- .../lit/reference/classes/QueryCache.md | 16 ++--- .../lit/reference/classes/QueryClient.md | 7 +- .../lit/reference/classes/QueryObserver.md | 38 ++++++++--- .../lit/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/shouldThrowError.md | 2 +- .../lit/reference/functions/useIsFetching.md | 4 +- .../lit/reference/functions/useIsMutating.md | 4 +- .../reference/functions/useMutationState.md | 4 +- .../lit/reference/interfaces/CancelOptions.md | 4 +- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../lit/reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../lit/reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../lit/reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../reference/interfaces/MutationOptions.md | 24 +++---- .../lit/reference/interfaces/MutationState.md | 18 ++--- .../lit/reference/interfaces/NotifyEvent.md | 2 +- .../lit/reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../lit/reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../lit/reference/interfaces/QueryOptions.md | 28 ++++---- .../lit/reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../lit/reference/interfaces/ResetOptions.md | 4 +- .../lit/reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../lit/reference/type-aliases/Accessor.md | 2 +- .../lit/reference/type-aliases/AnyDataTag.md | 4 +- .../CreateQueriesControllerOptions.md | 4 +- .../type-aliases/DefinedInitialDataOptions.md | 4 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../InfiniteQueryResultAccessor.md | 2 +- .../type-aliases/IsFetchingAccessor.md | 2 +- .../type-aliases/IsMutatingAccessor.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../type-aliases/MutationResultAccessor.md | 4 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/MutationStateAccessor.md | 2 +- .../type-aliases/MutationStateOptions.md | 4 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueriesResultAccessor.md | 2 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/QueryResultAccessor.md | 4 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../UndefinedInitialDataOptions.md | 2 +- .../type-aliases/UnusedSkipTokenOptions.md | 2 +- .../lit/reference/type-aliases/Updater.md | 2 +- .../reference/variables/environmentManager.md | 2 +- .../lit/reference/variables/notifyManager.md | 12 ++-- .../reference/classes/CancelledError.md | 8 +-- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../preact/reference/classes/MutationCache.md | 16 ++--- .../reference/classes/MutationObserver.md | 8 +-- .../reference/classes/QueriesObserver.md | 10 +-- .../preact/reference/classes/Query.md | 6 +- .../preact/reference/classes/QueryCache.md | 16 ++--- .../preact/reference/classes/QueryClient.md | 7 +- .../preact/reference/classes/QueryObserver.md | 38 ++++++++--- .../preact/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/shouldThrowError.md | 2 +- .../reference/functions/useMutationState.md | 4 +- .../preact/reference/functions/useQueries.md | 6 +- .../reference/functions/useSuspenseQueries.md | 10 +-- .../reference/interfaces/CancelOptions.md | 4 +- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../interfaces/HydrationBoundaryProps.md | 8 +-- .../reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../reference/interfaces/MutationOptions.md | 24 +++---- .../reference/interfaces/MutationState.md | 18 ++--- .../reference/interfaces/NotifyEvent.md | 2 +- .../reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../QueryErrorResetBoundaryProps.md | 2 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../reference/interfaces/QueryOptions.md | 28 ++++---- .../preact/reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../reference/interfaces/ResetOptions.md | 4 +- .../reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../interfaces/UseBaseQueryOptions.md | 56 ++++++++-------- .../interfaces/UseInfiniteQueryOptions.md | 60 ++++++++--------- .../interfaces/UseMutationOptions.md | 26 ++++---- .../reference/interfaces/UseQueryOptions.md | 54 +++++++-------- .../UseSuspenseInfiniteQueryOptions.md | 54 +++++++-------- .../interfaces/UseSuspenseQueryOptions.md | 48 +++++++------- .../reference/type-aliases/AnyDataTag.md | 4 +- .../DefinedInitialDataInfiniteOptions.md | 2 +- .../type-aliases/DefinedInitialDataOptions.md | 4 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryClientProviderProps.md | 4 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../UndefinedInitialDataInfiniteOptions.md | 2 +- .../UndefinedInitialDataOptions.md | 2 +- .../UnusedSkipTokenInfiniteOptions.md | 2 +- .../type-aliases/UnusedSkipTokenOptions.md | 2 +- .../preact/reference/type-aliases/Updater.md | 2 +- .../UsePrefetchInfiniteQueryOptions.md | 2 +- .../type-aliases/UsePrefetchQueryOptions.md | 2 +- .../reference/variables/environmentManager.md | 2 +- .../reference/variables/notifyManager.md | 12 ++-- .../react/reference/classes/CancelledError.md | 8 +-- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../react/reference/classes/MutationCache.md | 16 ++--- .../reference/classes/MutationObserver.md | 8 +-- .../reference/classes/QueriesObserver.md | 10 +-- .../react/reference/classes/Query.md | 6 +- .../react/reference/classes/QueryCache.md | 16 ++--- .../react/reference/classes/QueryClient.md | 7 +- .../react/reference/classes/QueryObserver.md | 38 ++++++++--- .../react/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/shouldThrowError.md | 2 +- .../reference/functions/useMutationState.md | 4 +- .../react/reference/functions/useQueries.md | 6 +- .../reference/functions/useSuspenseQueries.md | 10 +-- .../reference/interfaces/CancelOptions.md | 4 +- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../interfaces/HydrationBoundaryProps.md | 8 +-- .../reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../reference/interfaces/MutationOptions.md | 24 +++---- .../reference/interfaces/MutationState.md | 18 ++--- .../react/reference/interfaces/NotifyEvent.md | 2 +- .../reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../QueryErrorResetBoundaryProps.md | 2 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../reference/interfaces/QueryOptions.md | 28 ++++---- .../react/reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../reference/interfaces/ResetOptions.md | 4 +- .../reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../interfaces/UseBaseQueryOptions.md | 56 ++++++++-------- .../interfaces/UseInfiniteQueryOptions.md | 60 ++++++++--------- .../interfaces/UseMutationOptions.md | 26 ++++---- .../reference/interfaces/UseQueryOptions.md | 54 +++++++-------- .../UseSuspenseInfiniteQueryOptions.md | 54 +++++++-------- .../interfaces/UseSuspenseQueryOptions.md | 48 +++++++------- .../reference/type-aliases/AnyDataTag.md | 4 +- .../DefinedInitialDataInfiniteOptions.md | 2 +- .../type-aliases/DefinedInitialDataOptions.md | 4 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryClientProviderProps.md | 4 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../UndefinedInitialDataInfiniteOptions.md | 2 +- .../UndefinedInitialDataOptions.md | 2 +- .../UnusedSkipTokenInfiniteOptions.md | 2 +- .../type-aliases/UnusedSkipTokenOptions.md | 2 +- .../react/reference/type-aliases/Updater.md | 2 +- .../UsePrefetchInfiniteQueryOptions.md | 2 +- .../type-aliases/UsePrefetchQueryOptions.md | 2 +- .../reference/variables/environmentManager.md | 2 +- .../reference/variables/notifyManager.md | 12 ++-- .../solid/reference/classes/CancelledError.md | 8 +-- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../solid/reference/classes/MutationCache.md | 16 ++--- .../reference/classes/MutationObserver.md | 8 +-- .../reference/classes/QueriesObserver.md | 10 +-- .../solid/reference/classes/Query.md | 6 +- .../solid/reference/classes/QueryCache.md | 16 ++--- .../solid/reference/classes/QueryClient.md | 7 +- .../solid/reference/classes/QueryObserver.md | 38 ++++++++--- .../solid/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/shouldThrowError.md | 2 +- .../reference/functions/useMutationState.md | 4 +- .../solid/reference/functions/useQueries.md | 10 +-- .../reference/interfaces/CancelOptions.md | 4 +- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../interfaces/InfiniteQueryOptions.md | 62 ++++++++--------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../reference/interfaces/MutationOptions.md | 26 ++++---- .../reference/interfaces/MutationState.md | 18 ++--- .../solid/reference/interfaces/NotifyEvent.md | 2 +- .../reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../reference/interfaces/QueryOptions.md | 56 ++++++++-------- .../solid/reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../reference/interfaces/ResetOptions.md | 4 +- .../reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../interfaces/UseBaseQueryOptions.md | 56 ++++++++-------- .../reference/type-aliases/AnyDataTag.md | 4 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryClientProviderProps.md | 4 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../solid/reference/type-aliases/Updater.md | 2 +- .../reference/variables/QueryClientContext.md | 2 +- .../reference/variables/createQueries.md | 6 +- .../reference/variables/environmentManager.md | 2 +- .../reference/variables/notifyManager.md | 12 ++-- .../reference/classes/CancelledError.md | 8 +-- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../svelte/reference/classes/MutationCache.md | 16 ++--- .../reference/classes/MutationObserver.md | 8 +-- .../reference/classes/QueriesObserver.md | 10 +-- .../svelte/reference/classes/Query.md | 6 +- .../svelte/reference/classes/QueryCache.md | 16 ++--- .../svelte/reference/classes/QueryClient.md | 7 +- .../svelte/reference/classes/QueryObserver.md | 38 ++++++++--- .../reference/functions/createQueries.md | 10 +-- .../svelte/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/shouldThrowError.md | 2 +- .../reference/functions/useMutationState.md | 4 +- .../reference/interfaces/CancelOptions.md | 4 +- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../reference/interfaces/MutationOptions.md | 24 +++---- .../reference/interfaces/MutationState.md | 18 ++--- .../reference/interfaces/NotifyEvent.md | 2 +- .../reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../reference/interfaces/QueryOptions.md | 28 ++++---- .../svelte/reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../reference/interfaces/ResetOptions.md | 4 +- .../reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../reference/type-aliases/AnyDataTag.md | 4 +- .../DefinedInitialDataInfiniteOptions.md | 2 +- .../type-aliases/DefinedInitialDataOptions.md | 2 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/MutationStateOptions.md | 4 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryClientProviderProps.md | 4 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../UndefinedInitialDataInfiniteOptions.md | 2 +- .../UndefinedInitialDataOptions.md | 2 +- .../svelte/reference/type-aliases/Updater.md | 2 +- .../reference/variables/environmentManager.md | 2 +- .../reference/variables/notifyManager.md | 12 ++-- .../vue/reference/classes/CancelledError.md | 8 +-- .../classes/InfiniteQueryObserver.md | 40 +++++++---- .../vue/reference/classes/MutationCache.md | 16 ++--- .../vue/reference/classes/MutationObserver.md | 8 +-- .../vue/reference/classes/QueriesObserver.md | 10 +-- docs/framework/vue/reference/classes/Query.md | 6 +- .../vue/reference/classes/QueryCache.md | 16 ++--- .../vue/reference/classes/QueryClient.md | 31 +++++---- .../vue/reference/classes/QueryObserver.md | 38 ++++++++--- .../vue/reference/functions/dehydrate.md | 4 +- .../functions/experimental_streamedQuery.md | 40 +---------- .../reference/functions/keepPreviousData.md | 2 +- .../reference/functions/mutationOptions.md | 16 +---- .../vue/reference/functions/queryOptions.md | 16 +---- .../reference/functions/shouldThrowError.md | 2 +- .../vue/reference/functions/useIsFetching.md | 4 +- .../vue/reference/functions/useIsMutating.md | 4 +- .../reference/functions/useMutationState.md | 11 ++-- .../vue/reference/functions/useQueries.md | 2 +- .../vue/reference/functions/useQueryClient.md | 4 +- .../vue/reference/interfaces/CancelOptions.md | 4 +- .../reference/interfaces/DefaultOptions.md | 8 +-- .../reference/interfaces/DehydrateOptions.md | 8 +-- .../reference/interfaces/DehydratedState.md | 4 +- .../interfaces/EnsureQueryDataOptions.md | 34 +++++----- .../interfaces/FetchNextPageOptions.md | 4 +- .../interfaces/FetchPreviousPageOptions.md | 4 +- .../reference/interfaces/FetchQueryOptions.md | 32 ++++----- .../vue/reference/interfaces/FocusManager.md | 8 +-- .../reference/interfaces/HydrateOptions.md | 2 +- .../vue/reference/interfaces/InfiniteData.md | 4 +- .../InfiniteQueryObserverBaseResult.md | 66 +++++++++---------- ...InfiniteQueryObserverLoadingErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverOptions.md | 60 ++++++++--------- .../InfiniteQueryObserverPendingResult.md | 66 +++++++++---------- .../InfiniteQueryObserverPlaceholderResult.md | 66 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 66 +++++++++---------- .../InfiniteQueryObserverSuccessResult.md | 66 +++++++++---------- .../InfiniteQueryPageParamsOptions.md | 6 +- .../reference/interfaces/InitialPageParam.md | 2 +- .../reference/interfaces/InvalidateOptions.md | 4 +- .../interfaces/InvalidateQueryFilters.md | 14 ++-- .../vue/reference/interfaces/MutateOptions.md | 6 +- .../interfaces/MutationCacheConfig.md | 8 +-- .../reference/interfaces/MutationFilters.md | 8 +-- .../interfaces/MutationObserverBaseResult.md | 30 ++++----- .../interfaces/MutationObserverErrorResult.md | 30 ++++----- .../interfaces/MutationObserverIdleResult.md | 30 ++++----- .../MutationObserverLoadingResult.md | 30 ++++----- .../interfaces/MutationObserverOptions.md | 26 ++++---- .../MutationObserverSuccessResult.md | 30 ++++----- .../vue/reference/interfaces/MutationState.md | 18 ++--- .../vue/reference/interfaces/NotifyEvent.md | 2 +- .../vue/reference/interfaces/OnlineManager.md | 8 +-- .../interfaces/QueriesObserverOptions.md | 2 +- .../reference/interfaces/QueryCacheConfig.md | 6 +- .../reference/interfaces/QueryClientConfig.md | 6 +- .../interfaces/QueryExecuteOptions.md | 34 +++++----- .../vue/reference/interfaces/QueryFilters.md | 12 ++-- .../interfaces/QueryObserverBaseResult.md | 50 +++++++------- .../QueryObserverLoadingErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverLoadingResult.md | 50 +++++++------- .../interfaces/QueryObserverOptions.md | 54 +++++++-------- .../interfaces/QueryObserverPendingResult.md | 50 +++++++------- .../QueryObserverPlaceholderResult.md | 50 +++++++------- .../QueryObserverRefetchErrorResult.md | 50 +++++++------- .../interfaces/QueryObserverSuccessResult.md | 50 +++++++------- .../vue/reference/interfaces/QueryState.md | 24 +++---- .../reference/interfaces/RefetchOptions.md | 4 +- .../interfaces/RefetchQueryFilters.md | 12 ++-- .../vue/reference/interfaces/ResetOptions.md | 4 +- .../vue/reference/interfaces/ResultOptions.md | 2 +- .../reference/interfaces/SetDataOptions.md | 2 +- .../reference/interfaces/TimeoutManager.md | 20 ++++-- .../vue/reference/type-aliases/AnyDataTag.md | 4 +- .../DefinedInitialDataInfiniteOptions.md | 2 +- .../EnsureInfiniteQueryDataOptions.md | 2 +- .../type-aliases/MutationFunctionContext.md | 6 +- .../reference/type-aliases/MutationScope.md | 2 +- .../type-aliases/MutationStateOptions.md | 4 +- .../type-aliases/NotifyOnChangeProps.md | 4 +- .../type-aliases/PlaceholderDataFunction.md | 5 +- .../type-aliases/QueryBooleanOption.md | 2 +- .../type-aliases/QueryKeyWithDataTag.md | 2 +- .../type-aliases/StaleTimeFunction.md | 2 +- .../reference/type-aliases/ThrowOnError.md | 2 +- .../reference/type-aliases/TimeoutProvider.md | 8 +-- .../UndefinedInitialDataInfiniteOptions.md | 2 +- .../vue/reference/type-aliases/Updater.md | 2 +- .../type-aliases/UseIsFetchingFilters.md | 2 +- .../type-aliases/UseIsMutatingFilters.md | 2 +- .../type-aliases/UseMutationOptions.md | 2 +- .../UsePrefetchInfiniteQueryOptions.md | 2 +- .../type-aliases/UsePrefetchQueryOptions.md | 2 +- .../vue/reference/variables/VueQueryPlugin.md | 4 +- .../reference/variables/environmentManager.md | 2 +- .../vue/reference/variables/notifyManager.md | 12 ++-- 696 files changed, 6545 insertions(+), 6760 deletions(-) diff --git a/docs/framework/angular/reference/classes/CancelledError.md b/docs/framework/angular/reference/classes/CancelledError.md index 5bd8c049574..296c3e59d58 100644 --- a/docs/framework/angular/reference/classes/CancelledError.md +++ b/docs/framework/angular/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### cause? ```ts -optional cause: unknown; +optional cause?: unknown; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 @@ -107,7 +107,7 @@ Error.name ### revert? ```ts -optional revert: boolean; +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) @@ -117,7 +117,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) @@ -127,7 +127,7 @@ Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/ ### stack? ```ts -optional stack: string; +optional stack?: string; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 diff --git a/docs/framework/angular/reference/classes/InfiniteQueryObserver.md b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md index e4c49d4aad8..1a70c8ebf7f 100644 --- a/docs/framework/angular/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md @@ -122,7 +122,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -144,13 +144,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -384,7 +378,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -394,7 +388,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -530,7 +524,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/angular/reference/classes/MutationCache.md b/docs/framework/angular/reference/classes/MutationCache.md index b9d3b847527..4b8f85cab33 100644 --- a/docs/framework/angular/reference/classes/MutationCache.md +++ b/docs/framework/angular/reference/classes/MutationCache.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -147,7 +147,7 @@ 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) @@ -160,7 +160,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` @@ -253,13 +253,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/angular/reference/classes/MutationObserver.md b/docs/framework/angular/reference/classes/MutationObserver.md index d8170570502..87c7814735b 100644 --- a/docs/framework/angular/reference/classes/MutationObserver.md +++ b/docs/framework/angular/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/angular/reference/classes/QueriesObserver.md b/docs/framework/angular/reference/classes/QueriesObserver.md index ae3ccad54da..08c997c2d13 100644 --- a/docs/framework/angular/reference/classes/QueriesObserver.md +++ b/docs/framework/angular/reference/classes/QueriesObserver.md @@ -155,7 +155,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -262,13 +262,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/angular/reference/classes/Query.md b/docs/framework/angular/reference/classes/Query.md index 0d5b61737ba..c6b5f29ac9c 100644 --- a/docs/framework/angular/reference/classes/Query.md +++ b/docs/framework/angular/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/angular/reference/classes/QueryCache.md b/docs/framework/angular/reference/classes/QueryCache.md index f6fcffd0a62..b29348f1a4b 100644 --- a/docs/framework/angular/reference/classes/QueryCache.md +++ b/docs/framework/angular/reference/classes/QueryCache.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -214,7 +214,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) ### findAll() ```ts -findAll(filters: QueryFilters): Query[]; +findAll(filters?: QueryFilters): Query[]; ``` Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) @@ -227,7 +227,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` @@ -408,13 +408,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/angular/reference/classes/QueryClient.md b/docs/framework/angular/reference/classes/QueryClient.md index 1dcf71fbffb..07781860817 100644 --- a/docs/framework/angular/reference/classes/QueryClient.md +++ b/docs/framework/angular/reference/classes/QueryClient.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` @@ -189,7 +189,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns diff --git a/docs/framework/angular/reference/classes/QueryObserver.md b/docs/framework/angular/reference/classes/QueryObserver.md index 553457e08df..845acfe60cb 100644 --- a/docs/framework/angular/reference/classes/QueryObserver.md +++ b/docs/framework/angular/reference/classes/QueryObserver.md @@ -243,7 +243,7 @@ Subscribable.hasListeners ### 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) @@ -253,7 +253,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -362,13 +362,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -430,7 +424,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/angular/reference/functions/dehydrate.md b/docs/framework/angular/reference/functions/dehydrate.md index 201200efdfa..4999cadaf08 100644 --- a/docs/framework/angular/reference/functions/dehydrate.md +++ b/docs/framework/angular/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/angular/reference/functions/experimental_streamedQuery.md b/docs/framework/angular/reference/functions/experimental_streamedQuery.md index 29a8ae5d889..791a80817f2 100644 --- a/docs/framework/angular/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/angular/reference/functions/experimental_streamedQuery.md @@ -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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/angular/reference/functions/injectMutationState.md b/docs/framework/angular/reference/functions/injectMutationState.md index 2e43406cfee..96cdfc71dd9 100644 --- a/docs/framework/angular/reference/functions/injectMutationState.md +++ b/docs/framework/angular/reference/functions/injectMutationState.md @@ -4,7 +4,7 @@ title: injectMutationState --- ```ts -function injectMutationState(injectMutationStateFn: () => MutationStateOptions, options?: InjectMutationStateOptions): Signal; +function injectMutationState(injectMutationStateFn?: () => MutationStateOptions, options?: InjectMutationStateOptions): 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) @@ -20,7 +20,7 @@ Injects a signal that gives you access to all mutations in the `MutationCache`. ## Parameters -### injectMutationStateFn +### injectMutationStateFn? () => `MutationStateOptions`\<`TResult`\> diff --git a/docs/framework/angular/reference/functions/injectQueryClient.md b/docs/framework/angular/reference/functions/injectQueryClient.md index ba1298a498c..d16d6232b04 100644 --- a/docs/framework/angular/reference/functions/injectQueryClient.md +++ b/docs/framework/angular/reference/functions/injectQueryClient.md @@ -4,7 +4,7 @@ title: injectQueryClient --- ```ts -function injectQueryClient(injectOptions: InjectOptions & object): QueryClient; +function injectQueryClient(injectOptions?: InjectOptions & object): QueryClient; ``` Defined in: [packages/angular-query-experimental/src/inject-query-client.ts:18](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query-client.ts#L18) @@ -13,7 +13,7 @@ Injects a `QueryClient` instance and allows passing a custom injector. ## Parameters -### injectOptions +### injectOptions? `InjectOptions` & `object` = `{}` diff --git a/docs/framework/angular/reference/functions/keepPreviousData.md b/docs/framework/angular/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/angular/reference/functions/keepPreviousData.md +++ b/docs/framework/angular/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/angular/reference/functions/provideQueryClient.md b/docs/framework/angular/reference/functions/provideQueryClient.md index 8540552f034..13dad4e1596 100644 --- a/docs/framework/angular/reference/functions/provideQueryClient.md +++ b/docs/framework/angular/reference/functions/provideQueryClient.md @@ -20,9 +20,10 @@ it calls `provideQueryClient` internally. Use `provideQueryClient` directly to p ### queryClient -A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`. + \| [`QueryClient`](../classes/QueryClient.md) + \| `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\> -[`QueryClient`](../classes/QueryClient.md) | `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\> +A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`. ## Returns diff --git a/docs/framework/angular/reference/functions/provideTanStackQuery.md b/docs/framework/angular/reference/functions/provideTanStackQuery.md index d80b8bc9c11..0d7813a03be 100644 --- a/docs/framework/angular/reference/functions/provideTanStackQuery.md +++ b/docs/framework/angular/reference/functions/provideTanStackQuery.md @@ -18,9 +18,10 @@ configuring a `QueryClient` and optional features such as developer tools. ### queryClient -A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`. + \| [`QueryClient`](../classes/QueryClient.md) + \| `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\> -[`QueryClient`](../classes/QueryClient.md) | `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\> +A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`. ### features diff --git a/docs/framework/angular/reference/functions/shouldThrowError.md b/docs/framework/angular/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/angular/reference/functions/shouldThrowError.md +++ b/docs/framework/angular/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md b/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md index c3f71f3a8cf..0021f4b5b24 100644 --- a/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md +++ b/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md @@ -40,7 +40,7 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. | Property | Type | | ------ | ------ | -| `isError` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | -| `isIdle` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | -| `isPending` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | -| `isSuccess` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | +| `isError` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | +| `isIdle` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | +| `isPending` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | +| `isSuccess` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | diff --git a/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md b/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md index 44bb504262e..e4b6e653b78 100644 --- a/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md +++ b/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md @@ -28,6 +28,6 @@ The type of errors your `queryFn` may throw. | Property | Type | | ------ | ------ | -| `isError` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | -| `isPending` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | -| `isSuccess` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | +| `isError` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | +| `isPending` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | +| `isSuccess` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | diff --git a/docs/framework/angular/reference/interfaces/CancelOptions.md b/docs/framework/angular/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/angular/reference/interfaces/CancelOptions.md +++ b/docs/framework/angular/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md b/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md index f19f5b53089..e028c7224e5 100644 --- a/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md @@ -51,30 +51,30 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md b/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md index e4c7351f412..addcdd8b17c 100644 --- a/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md @@ -52,32 +52,32 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/CreateMutationOptions.md b/docs/framework/angular/reference/interfaces/CreateMutationOptions.md index 6136d4494e8..48bb7e42431 100644 --- a/docs/framework/angular/reference/interfaces/CreateMutationOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateMutationOptions.md @@ -43,16 +43,16 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/CreateQueryOptions.md b/docs/framework/angular/reference/interfaces/CreateQueryOptions.md index ff07a5c9125..5f9473f7e5d 100644 --- a/docs/framework/angular/reference/interfaces/CreateQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateQueryOptions.md @@ -43,29 +43,29 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryFnData` \| () => `TQueryFnData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/DefaultOptions.md b/docs/framework/angular/reference/interfaces/DefaultOptions.md index 7fae14fb540..9a73763ed09 100644 --- a/docs/framework/angular/reference/interfaces/DefaultOptions.md +++ b/docs/framework/angular/reference/interfaces/DefaultOptions.md @@ -15,10 +15,10 @@ Defined in: [packages/query-core/src/types.ts:1621](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | diff --git a/docs/framework/angular/reference/interfaces/DehydrateOptions.md b/docs/framework/angular/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/angular/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/angular/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/angular/reference/interfaces/DehydratedState.md b/docs/framework/angular/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/angular/reference/interfaces/DehydratedState.md +++ b/docs/framework/angular/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md b/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/angular/reference/interfaces/FetchQueryOptions.md b/docs/framework/angular/reference/interfaces/FetchQueryOptions.md index 19c4260bf7b..90e0625d587 100644 --- a/docs/framework/angular/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/angular/reference/interfaces/FocusManager.md b/docs/framework/angular/reference/interfaces/FocusManager.md index 71c585966d2..3d59e85c451 100644 --- a/docs/framework/angular/reference/interfaces/FocusManager.md +++ b/docs/framework/angular/reference/interfaces/FocusManager.md @@ -174,13 +174,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/angular/reference/interfaces/HydrateOptions.md b/docs/framework/angular/reference/interfaces/HydrateOptions.md index eccc9b8b513..30c57539b89 100644 --- a/docs/framework/angular/reference/interfaces/HydrateOptions.md +++ b/docs/framework/angular/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/angular/reference/interfaces/InfiniteData.md b/docs/framework/angular/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteData.md +++ b/docs/framework/angular/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md index d1642d98ff2..858435e5774 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md @@ -35,33 +35,33 @@ Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md index a07f20cadf8..a475eb9b048 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/angular/reference/interfaces/InitialPageParam.md b/docs/framework/angular/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/angular/reference/interfaces/InitialPageParam.md +++ b/docs/framework/angular/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md b/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md index d4db0ff3801..e5982249355 100644 --- a/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md @@ -9,4 +9,4 @@ Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:25 | Property | Type | Description | | ------ | ------ | ------ | -| `injector?` | `Injector` | The `Injector` in which to create the infinite query. If this is not provided, the current injection context will be used instead (via `inject`). | +| `injector?` | `Injector` | The `Injector` in which to create the infinite query. If this is not provided, the current injection context will be used instead (via `inject`). | diff --git a/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md b/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md index 7bda7143a0b..d0a6081701b 100644 --- a/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md @@ -9,4 +9,4 @@ Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:13](h | Property | Type | Description | | ------ | ------ | ------ | -| `injector?` | `Injector` | The `Injector` in which to create the isFetching signal. If this is not provided, the current injection context will be used instead (via `inject`). | +| `injector?` | `Injector` | The `Injector` in which to create the isFetching signal. If this is not provided, the current injection context will be used instead (via `inject`). | diff --git a/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md b/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md index 2db5b68f100..8e22d5b5569 100644 --- a/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md @@ -9,4 +9,4 @@ Defined in: [packages/angular-query-experimental/src/inject-is-mutating.ts:13](h | Property | Type | Description | | ------ | ------ | ------ | -| `injector?` | `Injector` | The `Injector` in which to create the isMutating signal. If this is not provided, the current injection context will be used instead (via `inject`). | +| `injector?` | `Injector` | The `Injector` in which to create the isMutating signal. If this is not provided, the current injection context will be used instead (via `inject`). | diff --git a/docs/framework/angular/reference/interfaces/InjectMutationOptions.md b/docs/framework/angular/reference/interfaces/InjectMutationOptions.md index 223b80433e0..50d85b7c95d 100644 --- a/docs/framework/angular/reference/interfaces/InjectMutationOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectMutationOptions.md @@ -9,4 +9,4 @@ Defined in: [packages/angular-query-experimental/src/inject-mutation.ts:28](http | Property | Type | Description | | ------ | ------ | ------ | -| `injector?` | `Injector` | The `Injector` in which to create the mutation. If this is not provided, the current injection context will be used instead (via `inject`). | +| `injector?` | `Injector` | The `Injector` in which to create the mutation. If this is not provided, the current injection context will be used instead (via `inject`). | diff --git a/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md b/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md index 7b1390974d3..05efad33ea0 100644 --- a/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md @@ -9,4 +9,4 @@ Defined in: [packages/angular-query-experimental/src/inject-mutation-state.ts:40 | Property | Type | Description | | ------ | ------ | ------ | -| `injector?` | `Injector` | The `Injector` in which to create the mutation state signal. If this is not provided, the current injection context will be used instead (via `inject`). | +| `injector?` | `Injector` | The `Injector` in which to create the mutation state signal. If this is not provided, the current injection context will be used instead (via `inject`). | diff --git a/docs/framework/angular/reference/interfaces/InjectQueryOptions.md b/docs/framework/angular/reference/interfaces/InjectQueryOptions.md index 6da34676e3f..f2c1fb4b029 100644 --- a/docs/framework/angular/reference/interfaces/InjectQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectQueryOptions.md @@ -9,4 +9,4 @@ Defined in: [packages/angular-query-experimental/src/inject-query.ts:20](https:/ | Property | Type | Description | | ------ | ------ | ------ | -| `injector?` | `Injector` | The `Injector` in which to create the query. If this is not provided, the current injection context will be used instead (via `inject`). | +| `injector?` | `Injector` | The `Injector` in which to create the query. If this is not provided, the current injection context will be used instead (via `inject`). | diff --git a/docs/framework/angular/reference/interfaces/InvalidateOptions.md b/docs/framework/angular/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/angular/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/angular/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/angular/reference/interfaces/MutateOptions.md b/docs/framework/angular/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/angular/reference/interfaces/MutateOptions.md +++ b/docs/framework/angular/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/angular/reference/interfaces/MutationCacheConfig.md b/docs/framework/angular/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/angular/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/angular/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/angular/reference/interfaces/MutationFilters.md b/docs/framework/angular/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/angular/reference/interfaces/MutationFilters.md +++ b/docs/framework/angular/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverOptions.md b/docs/framework/angular/reference/interfaces/MutationObserverOptions.md index 771cea89665..1920ce66911 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationOptions.md b/docs/framework/angular/reference/interfaces/MutationOptions.md index 323929c077d..9170d982368 100644 --- a/docs/framework/angular/reference/interfaces/MutationOptions.md +++ b/docs/framework/angular/reference/interfaces/MutationOptions.md @@ -31,15 +31,15 @@ Defined in: [packages/query-core/src/types.ts:1271](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | diff --git a/docs/framework/angular/reference/interfaces/MutationState.md b/docs/framework/angular/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/angular/reference/interfaces/MutationState.md +++ b/docs/framework/angular/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/angular/reference/interfaces/NotifyEvent.md b/docs/framework/angular/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/angular/reference/interfaces/NotifyEvent.md +++ b/docs/framework/angular/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/angular/reference/interfaces/OnlineManager.md b/docs/framework/angular/reference/interfaces/OnlineManager.md index 1ed3eebcf25..7e97e7bc137 100644 --- a/docs/framework/angular/reference/interfaces/OnlineManager.md +++ b/docs/framework/angular/reference/interfaces/OnlineManager.md @@ -151,13 +151,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md b/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/angular/reference/interfaces/QueryCacheConfig.md b/docs/framework/angular/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/angular/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/angular/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/angular/reference/interfaces/QueryClientConfig.md b/docs/framework/angular/reference/interfaces/QueryClientConfig.md index a314893a143..58fbbc0ffe7 100644 --- a/docs/framework/angular/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/angular/reference/interfaces/QueryClientConfig.md @@ -9,6 +9,6 @@ Defined in: [packages/query-core/src/types.ts:1609](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | -| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | -| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | +| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | +| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | diff --git a/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md b/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md index 4563e570678..49e37ad9f95 100644 --- a/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/angular/reference/interfaces/QueryFeature.md b/docs/framework/angular/reference/interfaces/QueryFeature.md index 17f74b4655a..0466508315f 100644 --- a/docs/framework/angular/reference/interfaces/QueryFeature.md +++ b/docs/framework/angular/reference/interfaces/QueryFeature.md @@ -17,5 +17,5 @@ Helper type to represent a Query feature. | Property | Type | | ------ | ------ | -| `ɵkind` | `TFeatureKind` | -| `ɵproviders` | `Provider`[] | +| `ɵkind` | `TFeatureKind` | +| `ɵproviders` | `Provider`[] | diff --git a/docs/framework/angular/reference/interfaces/QueryFilters.md b/docs/framework/angular/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/angular/reference/interfaces/QueryFilters.md +++ b/docs/framework/angular/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverOptions.md b/docs/framework/angular/reference/interfaces/QueryObserverOptions.md index 26cdba039fb..45c73142cc4 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverOptions.md @@ -44,30 +44,30 @@ Defined in: [packages/query-core/src/types.ts:432](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryOptions.md b/docs/framework/angular/reference/interfaces/QueryOptions.md index 3e4dbb3024a..966d8824818 100644 --- a/docs/framework/angular/reference/interfaces/QueryOptions.md +++ b/docs/framework/angular/reference/interfaces/QueryOptions.md @@ -31,17 +31,17 @@ Defined in: [packages/query-core/src/types.ts:276](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/angular/reference/interfaces/QueryState.md b/docs/framework/angular/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/angular/reference/interfaces/QueryState.md +++ b/docs/framework/angular/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/angular/reference/interfaces/RefetchOptions.md b/docs/framework/angular/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/angular/reference/interfaces/RefetchOptions.md +++ b/docs/framework/angular/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md b/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/angular/reference/interfaces/ResetOptions.md b/docs/framework/angular/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/angular/reference/interfaces/ResetOptions.md +++ b/docs/framework/angular/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/angular/reference/interfaces/ResultOptions.md b/docs/framework/angular/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/angular/reference/interfaces/ResultOptions.md +++ b/docs/framework/angular/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/angular/reference/interfaces/SetDataOptions.md b/docs/framework/angular/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/angular/reference/interfaces/SetDataOptions.md +++ b/docs/framework/angular/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/angular/reference/interfaces/TimeoutManager.md b/docs/framework/angular/reference/interfaces/TimeoutManager.md index 317213619d5..164487133a6 100644 --- a/docs/framework/angular/reference/interfaces/TimeoutManager.md +++ b/docs/framework/angular/reference/interfaces/TimeoutManager.md @@ -37,7 +37,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -58,7 +58,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -78,7 +80,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -99,7 +101,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -144,7 +148,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -192,7 +198,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/angular/reference/type-aliases/AnyDataTag.md b/docs/framework/angular/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/angular/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/angular/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index d4b42457136..175e930eac7 100644 --- a/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -19,7 +19,7 @@ never `undefined` (unless a `select` changes `TData` to include `undefined`). ```ts initialData: | NonUndefinedGuard> - | () => NonUndefinedGuard> + | (() => NonUndefinedGuard>) | undefined; ``` diff --git a/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md index e37476fa74d..eab07dff2e5 100644 --- a/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md @@ -19,7 +19,7 @@ The options accepted by the `queryOptions` overload selected when `initialData` ```ts initialData: | NonUndefinedGuard -| () => NonUndefinedGuard; + | (() => NonUndefinedGuard); ``` If set, this value will be used as the initial data for the query cache (as long as the query hasn't been @@ -31,7 +31,7 @@ cache. ### queryFn? ```ts -optional queryFn: QueryFunction; +optional queryFn?: QueryFunction; ``` Optional here, but omitting it is only safe when no fetch will be attempted — for example with diff --git a/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md b/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md index 5cb260a4371..6dbc2879129 100644 --- a/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | [`QueryClient`](../classes/QueryClient.md) | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/angular/reference/type-aliases/MutationScope.md b/docs/framework/angular/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/angular/reference/type-aliases/MutationScope.md +++ b/docs/framework/angular/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md index 9191c25c7d9..9b658cb5e6b 100644 --- a/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md index d35d6161a39..fc88186764a 100644 --- a/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md b/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md index 45daab83127..5a63f8dae29 100644 --- a/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md b/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md index 761e1af5402..ba9b538fa66 100644 --- a/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/angular/reference/type-aliases/ThrowOnError.md b/docs/framework/angular/reference/type-aliases/ThrowOnError.md index ffed6038ff5..40b1fcd4739 100644 --- a/docs/framework/angular/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/angular/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/angular/reference/type-aliases/TimeoutProvider.md b/docs/framework/angular/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/angular/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/angular/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index e657351693d..fb45d9bce33 100644 --- a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -17,7 +17,7 @@ may be `undefined` while the query is `pending`. ### initialData? ```ts -optional initialData: +optional initialData?: | NonUndefinedGuard> | InitialDataFunction>>; ``` diff --git a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md index 3814e441388..3aed411ed0a 100644 --- a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md @@ -17,7 +17,7 @@ The options accepted by the `queryOptions` overload selected when no `initialDat ### initialData? ```ts -optional initialData: +optional initialData?: | InitialDataFunction> | NonUndefinedGuard; ``` diff --git a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md index ec9ab5c61dd..27a15e4f8ee 100644 --- a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md +++ b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md @@ -18,7 +18,7 @@ The options accepted by the `infiniteQueryOptions` overload selected when no `in ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If diff --git a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md index 854d773b68e..bf1c82d76ef 100644 --- a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md @@ -17,7 +17,7 @@ not `skipToken` — same as [UndefinedInitialDataOptions](UndefinedInitialDataOp ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If diff --git a/docs/framework/angular/reference/type-aliases/Updater.md b/docs/framework/angular/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/angular/reference/type-aliases/Updater.md +++ b/docs/framework/angular/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/angular/reference/variables/environmentManager.md b/docs/framework/angular/reference/variables/environmentManager.md index 4f88d27d2a9..1b5f65b6a99 100644 --- a/docs/framework/angular/reference/variables/environmentManager.md +++ b/docs/framework/angular/reference/variables/environmentManager.md @@ -20,7 +20,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/angular/reference/variables/notifyManager.md b/docs/framework/angular/reference/variables/notifyManager.md index c2c071b42a5..abc590e3442 100644 --- a/docs/framework/angular/reference/variables/notifyManager.md +++ b/docs/framework/angular/reference/variables/notifyManager.md @@ -13,7 +13,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -40,7 +40,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -64,7 +64,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -83,7 +83,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -112,7 +112,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -131,7 +131,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; diff --git a/docs/framework/lit/reference/classes/CancelledError.md b/docs/framework/lit/reference/classes/CancelledError.md index f0ba926026f..0f4c37ede92 100644 --- a/docs/framework/lit/reference/classes/CancelledError.md +++ b/docs/framework/lit/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### revert? ```ts -optional revert: boolean; +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) @@ -69,7 +69,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) diff --git a/docs/framework/lit/reference/classes/InfiniteQueryObserver.md b/docs/framework/lit/reference/classes/InfiniteQueryObserver.md index 67e74e09f40..13c5e088537 100644 --- a/docs/framework/lit/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/lit/reference/classes/InfiniteQueryObserver.md @@ -122,7 +122,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -144,13 +144,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -384,7 +378,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -394,7 +388,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -530,7 +524,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/lit/reference/classes/MutationCache.md b/docs/framework/lit/reference/classes/MutationCache.md index 22105e4908d..25f3b785266 100644 --- a/docs/framework/lit/reference/classes/MutationCache.md +++ b/docs/framework/lit/reference/classes/MutationCache.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -147,7 +147,7 @@ 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) @@ -160,7 +160,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` @@ -253,13 +253,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/lit/reference/classes/MutationObserver.md b/docs/framework/lit/reference/classes/MutationObserver.md index d8170570502..87c7814735b 100644 --- a/docs/framework/lit/reference/classes/MutationObserver.md +++ b/docs/framework/lit/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/lit/reference/classes/QueriesObserver.md b/docs/framework/lit/reference/classes/QueriesObserver.md index 1fb8b49268f..74f877cc70d 100644 --- a/docs/framework/lit/reference/classes/QueriesObserver.md +++ b/docs/framework/lit/reference/classes/QueriesObserver.md @@ -155,7 +155,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -262,13 +262,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/lit/reference/classes/Query.md b/docs/framework/lit/reference/classes/Query.md index 0d5b61737ba..c6b5f29ac9c 100644 --- a/docs/framework/lit/reference/classes/Query.md +++ b/docs/framework/lit/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/lit/reference/classes/QueryCache.md b/docs/framework/lit/reference/classes/QueryCache.md index 6b0039eec20..3a267e7bb1b 100644 --- a/docs/framework/lit/reference/classes/QueryCache.md +++ b/docs/framework/lit/reference/classes/QueryCache.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -214,7 +214,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) ### findAll() ```ts -findAll(filters: QueryFilters): Query[]; +findAll(filters?: QueryFilters): Query[]; ``` Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) @@ -227,7 +227,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` @@ -408,13 +408,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/lit/reference/classes/QueryClient.md b/docs/framework/lit/reference/classes/QueryClient.md index 45dd200d7a2..e24c8c646ff 100644 --- a/docs/framework/lit/reference/classes/QueryClient.md +++ b/docs/framework/lit/reference/classes/QueryClient.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` @@ -189,7 +189,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns diff --git a/docs/framework/lit/reference/classes/QueryObserver.md b/docs/framework/lit/reference/classes/QueryObserver.md index 6dbb24ce3ea..5f4c6d7ac96 100644 --- a/docs/framework/lit/reference/classes/QueryObserver.md +++ b/docs/framework/lit/reference/classes/QueryObserver.md @@ -243,7 +243,7 @@ Subscribable.hasListeners ### 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) @@ -253,7 +253,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -362,13 +362,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -430,7 +424,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/lit/reference/functions/dehydrate.md b/docs/framework/lit/reference/functions/dehydrate.md index 201200efdfa..4999cadaf08 100644 --- a/docs/framework/lit/reference/functions/dehydrate.md +++ b/docs/framework/lit/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/lit/reference/functions/experimental_streamedQuery.md b/docs/framework/lit/reference/functions/experimental_streamedQuery.md index 29a8ae5d889..791a80817f2 100644 --- a/docs/framework/lit/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/lit/reference/functions/experimental_streamedQuery.md @@ -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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/lit/reference/functions/keepPreviousData.md b/docs/framework/lit/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/lit/reference/functions/keepPreviousData.md +++ b/docs/framework/lit/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/lit/reference/functions/shouldThrowError.md b/docs/framework/lit/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/lit/reference/functions/shouldThrowError.md +++ b/docs/framework/lit/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/lit/reference/functions/useIsFetching.md b/docs/framework/lit/reference/functions/useIsFetching.md index e8843de6028..12c6949ca0e 100644 --- a/docs/framework/lit/reference/functions/useIsFetching.md +++ b/docs/framework/lit/reference/functions/useIsFetching.md @@ -6,7 +6,7 @@ title: useIsFetching ```ts function useIsFetching( host: ReactiveControllerHost, - filters: Accessor>, + filters?: Accessor>, queryClient?: QueryClient): IsFetchingAccessor; ``` @@ -28,7 +28,7 @@ resolves the client from the nearest connected `QueryClientProvider`. The Lit reactive controller host that owns the cache subscription. -### filters +### filters? [`Accessor`](../type-aliases/Accessor.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` diff --git a/docs/framework/lit/reference/functions/useIsMutating.md b/docs/framework/lit/reference/functions/useIsMutating.md index 16df7287a70..acf824ff1c9 100644 --- a/docs/framework/lit/reference/functions/useIsMutating.md +++ b/docs/framework/lit/reference/functions/useIsMutating.md @@ -6,7 +6,7 @@ title: useIsMutating ```ts function useIsMutating( host: ReactiveControllerHost, - filters: Accessor>, + filters?: Accessor>, queryClient?: QueryClient): IsMutatingAccessor; ``` @@ -28,7 +28,7 @@ resolves the client from the nearest connected `QueryClientProvider`. The Lit reactive controller host that owns the cache subscription. -### filters +### filters? [`Accessor`](../type-aliases/Accessor.md)\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` diff --git a/docs/framework/lit/reference/functions/useMutationState.md b/docs/framework/lit/reference/functions/useMutationState.md index c62bbb8d19e..c076d3d47bf 100644 --- a/docs/framework/lit/reference/functions/useMutationState.md +++ b/docs/framework/lit/reference/functions/useMutationState.md @@ -6,7 +6,7 @@ title: useMutationState ```ts function useMutationState( host: ReactiveControllerHost, - options: MutationStateOptions, + options?: MutationStateOptions, queryClient?: QueryClient): MutationStateAccessor; ``` @@ -35,7 +35,7 @@ the controller resolves the client from the nearest connected The Lit reactive controller host that owns the mutation cache subscription. -### options +### options? [`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`\> = `{}` diff --git a/docs/framework/lit/reference/interfaces/CancelOptions.md b/docs/framework/lit/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/lit/reference/interfaces/CancelOptions.md +++ b/docs/framework/lit/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/lit/reference/interfaces/DefaultOptions.md b/docs/framework/lit/reference/interfaces/DefaultOptions.md index 7fae14fb540..9a73763ed09 100644 --- a/docs/framework/lit/reference/interfaces/DefaultOptions.md +++ b/docs/framework/lit/reference/interfaces/DefaultOptions.md @@ -15,10 +15,10 @@ Defined in: [packages/query-core/src/types.ts:1621](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | diff --git a/docs/framework/lit/reference/interfaces/DehydrateOptions.md b/docs/framework/lit/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/lit/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/lit/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/lit/reference/interfaces/DehydratedState.md b/docs/framework/lit/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/lit/reference/interfaces/DehydratedState.md +++ b/docs/framework/lit/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md b/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/lit/reference/interfaces/FetchQueryOptions.md b/docs/framework/lit/reference/interfaces/FetchQueryOptions.md index 19c4260bf7b..90e0625d587 100644 --- a/docs/framework/lit/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/lit/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/lit/reference/interfaces/FocusManager.md b/docs/framework/lit/reference/interfaces/FocusManager.md index 71c585966d2..3d59e85c451 100644 --- a/docs/framework/lit/reference/interfaces/FocusManager.md +++ b/docs/framework/lit/reference/interfaces/FocusManager.md @@ -174,13 +174,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/lit/reference/interfaces/HydrateOptions.md b/docs/framework/lit/reference/interfaces/HydrateOptions.md index eccc9b8b513..30c57539b89 100644 --- a/docs/framework/lit/reference/interfaces/HydrateOptions.md +++ b/docs/framework/lit/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/lit/reference/interfaces/InfiniteData.md b/docs/framework/lit/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteData.md +++ b/docs/framework/lit/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md index d1642d98ff2..858435e5774 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md @@ -35,33 +35,33 @@ Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md index a07f20cadf8..a475eb9b048 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/lit/reference/interfaces/InitialPageParam.md b/docs/framework/lit/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/lit/reference/interfaces/InitialPageParam.md +++ b/docs/framework/lit/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/lit/reference/interfaces/InvalidateOptions.md b/docs/framework/lit/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/lit/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/lit/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/lit/reference/interfaces/MutateOptions.md b/docs/framework/lit/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/lit/reference/interfaces/MutateOptions.md +++ b/docs/framework/lit/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/lit/reference/interfaces/MutationCacheConfig.md b/docs/framework/lit/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/lit/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/lit/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/lit/reference/interfaces/MutationFilters.md b/docs/framework/lit/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/lit/reference/interfaces/MutationFilters.md +++ b/docs/framework/lit/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverOptions.md b/docs/framework/lit/reference/interfaces/MutationObserverOptions.md index 771cea89665..1920ce66911 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationOptions.md b/docs/framework/lit/reference/interfaces/MutationOptions.md index 323929c077d..9170d982368 100644 --- a/docs/framework/lit/reference/interfaces/MutationOptions.md +++ b/docs/framework/lit/reference/interfaces/MutationOptions.md @@ -31,15 +31,15 @@ Defined in: [packages/query-core/src/types.ts:1271](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | diff --git a/docs/framework/lit/reference/interfaces/MutationState.md b/docs/framework/lit/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/lit/reference/interfaces/MutationState.md +++ b/docs/framework/lit/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/lit/reference/interfaces/NotifyEvent.md b/docs/framework/lit/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/lit/reference/interfaces/NotifyEvent.md +++ b/docs/framework/lit/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/lit/reference/interfaces/OnlineManager.md b/docs/framework/lit/reference/interfaces/OnlineManager.md index 1ed3eebcf25..7e97e7bc137 100644 --- a/docs/framework/lit/reference/interfaces/OnlineManager.md +++ b/docs/framework/lit/reference/interfaces/OnlineManager.md @@ -151,13 +151,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md b/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/lit/reference/interfaces/QueryCacheConfig.md b/docs/framework/lit/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/lit/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/lit/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/lit/reference/interfaces/QueryClientConfig.md b/docs/framework/lit/reference/interfaces/QueryClientConfig.md index a314893a143..58fbbc0ffe7 100644 --- a/docs/framework/lit/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/lit/reference/interfaces/QueryClientConfig.md @@ -9,6 +9,6 @@ Defined in: [packages/query-core/src/types.ts:1609](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | -| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | -| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | +| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | +| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | diff --git a/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md b/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md index 4563e570678..49e37ad9f95 100644 --- a/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/lit/reference/interfaces/QueryFilters.md b/docs/framework/lit/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/lit/reference/interfaces/QueryFilters.md +++ b/docs/framework/lit/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverOptions.md b/docs/framework/lit/reference/interfaces/QueryObserverOptions.md index 9149bc22de4..b432ed89a0c 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverOptions.md @@ -43,30 +43,30 @@ Defined in: [packages/query-core/src/types.ts:432](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryOptions.md b/docs/framework/lit/reference/interfaces/QueryOptions.md index 3e4dbb3024a..966d8824818 100644 --- a/docs/framework/lit/reference/interfaces/QueryOptions.md +++ b/docs/framework/lit/reference/interfaces/QueryOptions.md @@ -31,17 +31,17 @@ Defined in: [packages/query-core/src/types.ts:276](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/lit/reference/interfaces/QueryState.md b/docs/framework/lit/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/lit/reference/interfaces/QueryState.md +++ b/docs/framework/lit/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/lit/reference/interfaces/RefetchOptions.md b/docs/framework/lit/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/lit/reference/interfaces/RefetchOptions.md +++ b/docs/framework/lit/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md b/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/lit/reference/interfaces/ResetOptions.md b/docs/framework/lit/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/lit/reference/interfaces/ResetOptions.md +++ b/docs/framework/lit/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/lit/reference/interfaces/ResultOptions.md b/docs/framework/lit/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/lit/reference/interfaces/ResultOptions.md +++ b/docs/framework/lit/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/lit/reference/interfaces/SetDataOptions.md b/docs/framework/lit/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/lit/reference/interfaces/SetDataOptions.md +++ b/docs/framework/lit/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/lit/reference/interfaces/TimeoutManager.md b/docs/framework/lit/reference/interfaces/TimeoutManager.md index 317213619d5..164487133a6 100644 --- a/docs/framework/lit/reference/interfaces/TimeoutManager.md +++ b/docs/framework/lit/reference/interfaces/TimeoutManager.md @@ -37,7 +37,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -58,7 +58,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -78,7 +80,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -99,7 +101,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -144,7 +148,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -192,7 +198,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/lit/reference/type-aliases/Accessor.md b/docs/framework/lit/reference/type-aliases/Accessor.md index 4a3dc666659..0abc843a591 100644 --- a/docs/framework/lit/reference/type-aliases/Accessor.md +++ b/docs/framework/lit/reference/type-aliases/Accessor.md @@ -4,7 +4,7 @@ title: Accessor --- ```ts -type Accessor = T | () => T; +type Accessor = T | (() => T); ``` Defined in: [packages/lit-query/src/accessor.ts:13](https://github.com/TanStack/query/blob/main/packages/lit-query/src/accessor.ts#L13) diff --git a/docs/framework/lit/reference/type-aliases/AnyDataTag.md b/docs/framework/lit/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/lit/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/lit/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/lit/reference/type-aliases/CreateQueriesControllerOptions.md b/docs/framework/lit/reference/type-aliases/CreateQueriesControllerOptions.md index 1bce7575749..61a4a3dd9e8 100644 --- a/docs/framework/lit/reference/type-aliases/CreateQueriesControllerOptions.md +++ b/docs/framework/lit/reference/type-aliases/CreateQueriesControllerOptions.md @@ -29,5 +29,5 @@ returned accessor. | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | (`result`: `CreateQueriesResults`\<`TQueryOptions`\>) => `TCombinedResult` | Optional function that combines the query result array into one value. | -| `queries` | [`Accessor`](Accessor.md)\< \| readonly \[`...CreateQueriesOptions`\] \| readonly \[`...{ [K in keyof TQueryOptions]: GetCreateQueriesInput }`\]\> | Query options to observe, or a getter that returns the current options. | +| `combine?` | (`result`: `CreateQueriesResults`\<`TQueryOptions`\>) => `TCombinedResult` | Optional function that combines the query result array into one value. | +| `queries` | [`Accessor`](Accessor.md)\< \| readonly \[`...CreateQueriesOptions`\] \| readonly \[`...{ [K in keyof TQueryOptions]: GetCreateQueriesInput }`\]\> | Query options to observe, or a getter that returns the current options. | diff --git a/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md index f2be44efd8a..5946580b831 100644 --- a/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md @@ -18,13 +18,13 @@ Query options with `initialData` that guarantees defined query data. ```ts initialData: | NonUndefinedGuard -| () => NonUndefinedGuard; + | (() => NonUndefinedGuard); ``` ### queryFn? ```ts -optional queryFn: QueryFunction; +optional queryFn?: QueryFunction; ``` ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/InfiniteQueryResultAccessor.md b/docs/framework/lit/reference/type-aliases/InfiniteQueryResultAccessor.md index a9ac9731562..4a6e5bbc501 100644 --- a/docs/framework/lit/reference/type-aliases/InfiniteQueryResultAccessor.md +++ b/docs/framework/lit/reference/type-aliases/InfiniteQueryResultAccessor.md @@ -17,7 +17,7 @@ observer. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; diff --git a/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md b/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md index e7ee64eb355..adc86a66d70 100644 --- a/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md +++ b/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md @@ -16,7 +16,7 @@ currently fetching queries that match the filters. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; diff --git a/docs/framework/lit/reference/type-aliases/IsMutatingAccessor.md b/docs/framework/lit/reference/type-aliases/IsMutatingAccessor.md index edeaa9d7f86..8747f533bd1 100644 --- a/docs/framework/lit/reference/type-aliases/IsMutatingAccessor.md +++ b/docs/framework/lit/reference/type-aliases/IsMutatingAccessor.md @@ -16,7 +16,7 @@ currently pending mutations that match the filters. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; diff --git a/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md b/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md index 5cb260a4371..6dbc2879129 100644 --- a/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | [`QueryClient`](../classes/QueryClient.md) | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md b/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md index ac6f24a0c83..8a41b3f3510 100644 --- a/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md +++ b/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md @@ -16,7 +16,7 @@ result. The attached methods delegate to the active mutation observer. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; @@ -28,7 +28,7 @@ Removes the controller from its Lit host and unsubscribes observers. `void` -### mutate() +### mutate ```ts mutate: (...args: Parameters>) => void; diff --git a/docs/framework/lit/reference/type-aliases/MutationScope.md b/docs/framework/lit/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/lit/reference/type-aliases/MutationScope.md +++ b/docs/framework/lit/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/lit/reference/type-aliases/MutationStateAccessor.md b/docs/framework/lit/reference/type-aliases/MutationStateAccessor.md index b169d4c1280..529bd460d69 100644 --- a/docs/framework/lit/reference/type-aliases/MutationStateAccessor.md +++ b/docs/framework/lit/reference/type-aliases/MutationStateAccessor.md @@ -16,7 +16,7 @@ matching mutations. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; diff --git a/docs/framework/lit/reference/type-aliases/MutationStateOptions.md b/docs/framework/lit/reference/type-aliases/MutationStateOptions.md index f1ae35905b5..b62215719f1 100644 --- a/docs/framework/lit/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/lit/reference/type-aliases/MutationStateOptions.md @@ -21,5 +21,5 @@ Options accepted by `useMutationState`. | Property | Type | Description | | ------ | ------ | ------ | -| `filters?` | [`Accessor`](Accessor.md)\<[`MutationFilters`](../interfaces/MutationFilters.md)\> | Filters used to select mutations from the mutation cache. | -| `select?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `TResult` | Maps each matching mutation to the value returned by the accessor. | +| `filters?` | [`Accessor`](Accessor.md)\<[`MutationFilters`](../interfaces/MutationFilters.md)\> | Filters used to select mutations from the mutation cache. | +| `select?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `TResult` | Maps each matching mutation to the value returned by the accessor. | diff --git a/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md index 690522642b8..1f789597ed3 100644 --- a/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md index 5479f66e83a..405e4073cf9 100644 --- a/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/lit/reference/type-aliases/QueriesResultAccessor.md b/docs/framework/lit/reference/type-aliases/QueriesResultAccessor.md index 30f461abec0..4ad70d986d6 100644 --- a/docs/framework/lit/reference/type-aliases/QueriesResultAccessor.md +++ b/docs/framework/lit/reference/type-aliases/QueriesResultAccessor.md @@ -16,7 +16,7 @@ value. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; diff --git a/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md b/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md index 92eb4850cb1..c8a6e077c79 100644 --- a/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md b/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md index 49b2b4ecc33..35179119f66 100644 --- a/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md +++ b/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md @@ -16,7 +16,7 @@ result. The attached methods delegate to the active query observer. ## Type Declaration -### destroy() +### destroy ```ts destroy: () => void; @@ -36,7 +36,7 @@ refetch: QueryObserverResult["refetch"]; Refetches the current query. -### suspense() +### suspense ```ts suspense: () => Promise>; diff --git a/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md b/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md index 5495c20c2bd..4f41081ceec 100644 --- a/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/lit/reference/type-aliases/ThrowOnError.md b/docs/framework/lit/reference/type-aliases/ThrowOnError.md index d831573e73c..34d215d62e1 100644 --- a/docs/framework/lit/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/lit/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/lit/reference/type-aliases/TimeoutProvider.md b/docs/framework/lit/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/lit/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/lit/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md index cb39415a6c1..ddc3531cbbf 100644 --- a/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md @@ -16,7 +16,7 @@ Query options where `initialData` can be omitted or undefined. ### initialData? ```ts -optional initialData: +optional initialData?: | InitialDataFunction> | NonUndefinedGuard; ``` diff --git a/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md index 12cc895e53f..431a6fbd16f 100644 --- a/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md @@ -16,7 +16,7 @@ Query options where `queryFn` is present and not a `skipToken`. ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/Updater.md b/docs/framework/lit/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/lit/reference/type-aliases/Updater.md +++ b/docs/framework/lit/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/lit/reference/variables/environmentManager.md b/docs/framework/lit/reference/variables/environmentManager.md index 4f88d27d2a9..1b5f65b6a99 100644 --- a/docs/framework/lit/reference/variables/environmentManager.md +++ b/docs/framework/lit/reference/variables/environmentManager.md @@ -20,7 +20,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/lit/reference/variables/notifyManager.md b/docs/framework/lit/reference/variables/notifyManager.md index c2c071b42a5..abc590e3442 100644 --- a/docs/framework/lit/reference/variables/notifyManager.md +++ b/docs/framework/lit/reference/variables/notifyManager.md @@ -13,7 +13,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -40,7 +40,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -64,7 +64,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -83,7 +83,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -112,7 +112,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -131,7 +131,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; diff --git a/docs/framework/preact/reference/classes/CancelledError.md b/docs/framework/preact/reference/classes/CancelledError.md index 5bd8c049574..296c3e59d58 100644 --- a/docs/framework/preact/reference/classes/CancelledError.md +++ b/docs/framework/preact/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### cause? ```ts -optional cause: unknown; +optional cause?: unknown; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 @@ -107,7 +107,7 @@ Error.name ### revert? ```ts -optional revert: boolean; +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) @@ -117,7 +117,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) @@ -127,7 +127,7 @@ Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/ ### stack? ```ts -optional stack: string; +optional stack?: string; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 diff --git a/docs/framework/preact/reference/classes/InfiniteQueryObserver.md b/docs/framework/preact/reference/classes/InfiniteQueryObserver.md index e4c49d4aad8..1a70c8ebf7f 100644 --- a/docs/framework/preact/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/preact/reference/classes/InfiniteQueryObserver.md @@ -122,7 +122,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -144,13 +144,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -384,7 +378,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -394,7 +388,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -530,7 +524,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/preact/reference/classes/MutationCache.md b/docs/framework/preact/reference/classes/MutationCache.md index b9d3b847527..4b8f85cab33 100644 --- a/docs/framework/preact/reference/classes/MutationCache.md +++ b/docs/framework/preact/reference/classes/MutationCache.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -147,7 +147,7 @@ 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) @@ -160,7 +160,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` @@ -253,13 +253,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/preact/reference/classes/MutationObserver.md b/docs/framework/preact/reference/classes/MutationObserver.md index d8170570502..87c7814735b 100644 --- a/docs/framework/preact/reference/classes/MutationObserver.md +++ b/docs/framework/preact/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/preact/reference/classes/QueriesObserver.md b/docs/framework/preact/reference/classes/QueriesObserver.md index ae3ccad54da..08c997c2d13 100644 --- a/docs/framework/preact/reference/classes/QueriesObserver.md +++ b/docs/framework/preact/reference/classes/QueriesObserver.md @@ -155,7 +155,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -262,13 +262,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/preact/reference/classes/Query.md b/docs/framework/preact/reference/classes/Query.md index 0d5b61737ba..c6b5f29ac9c 100644 --- a/docs/framework/preact/reference/classes/Query.md +++ b/docs/framework/preact/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/preact/reference/classes/QueryCache.md b/docs/framework/preact/reference/classes/QueryCache.md index f6fcffd0a62..b29348f1a4b 100644 --- a/docs/framework/preact/reference/classes/QueryCache.md +++ b/docs/framework/preact/reference/classes/QueryCache.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -214,7 +214,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) ### findAll() ```ts -findAll(filters: QueryFilters): Query[]; +findAll(filters?: QueryFilters): Query[]; ``` Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) @@ -227,7 +227,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` @@ -408,13 +408,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/preact/reference/classes/QueryClient.md b/docs/framework/preact/reference/classes/QueryClient.md index 1dcf71fbffb..07781860817 100644 --- a/docs/framework/preact/reference/classes/QueryClient.md +++ b/docs/framework/preact/reference/classes/QueryClient.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` @@ -189,7 +189,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns diff --git a/docs/framework/preact/reference/classes/QueryObserver.md b/docs/framework/preact/reference/classes/QueryObserver.md index 553457e08df..845acfe60cb 100644 --- a/docs/framework/preact/reference/classes/QueryObserver.md +++ b/docs/framework/preact/reference/classes/QueryObserver.md @@ -243,7 +243,7 @@ Subscribable.hasListeners ### 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) @@ -253,7 +253,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -362,13 +362,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -430,7 +424,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/preact/reference/functions/dehydrate.md b/docs/framework/preact/reference/functions/dehydrate.md index 201200efdfa..4999cadaf08 100644 --- a/docs/framework/preact/reference/functions/dehydrate.md +++ b/docs/framework/preact/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/preact/reference/functions/experimental_streamedQuery.md b/docs/framework/preact/reference/functions/experimental_streamedQuery.md index 29a8ae5d889..791a80817f2 100644 --- a/docs/framework/preact/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/preact/reference/functions/experimental_streamedQuery.md @@ -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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/preact/reference/functions/keepPreviousData.md b/docs/framework/preact/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/preact/reference/functions/keepPreviousData.md +++ b/docs/framework/preact/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/preact/reference/functions/shouldThrowError.md b/docs/framework/preact/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/preact/reference/functions/shouldThrowError.md +++ b/docs/framework/preact/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/preact/reference/functions/useMutationState.md b/docs/framework/preact/reference/functions/useMutationState.md index aad16d31fc9..86e990cdf9f 100644 --- a/docs/framework/preact/reference/functions/useMutationState.md +++ b/docs/framework/preact/reference/functions/useMutationState.md @@ -4,7 +4,7 @@ title: useMutationState --- ```ts -function useMutationState(options: MutationStateOptions, queryClient?: QueryClient): TResult[]; +function useMutationState(options?: MutationStateOptions, queryClient?: QueryClient): TResult[]; ``` Defined in: [packages/preact-query/src/useMutationState.ts:157](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutationState.ts#L157) @@ -25,7 +25,7 @@ state. ## Parameters -### options +### options? `MutationStateOptions`\<`TResult`, `TMutation`\> = `{}` diff --git a/docs/framework/preact/reference/functions/useQueries.md b/docs/framework/preact/reference/functions/useQueries.md index f74199b4aaf..cebc30930b3 100644 --- a/docs/framework/preact/reference/functions/useQueries.md +++ b/docs/framework/preact/reference/functions/useQueries.md @@ -30,7 +30,7 @@ be structurally shared to be as referentially stable as possible. ### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \} ## Parameters @@ -38,7 +38,7 @@ be structurally shared to be as referentially stable as possible. #### combine? -(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \}) => `TCombinedResult` +(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \}) => `TCombinedResult` Use this to combine the results of the queries into a single value. The result will be structurally shared to be as referentially stable as possible. @@ -46,7 +46,7 @@ shared to be as referentially stable as possible. #### queries \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryOptionsForUseQueries`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryOptionsForUseQueries`\<`Head`\>, `GetUseQueryOptionsForUseQueries`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : readonly ...[] *extends* \[`...(...)[]`\] ? \[`...(...)[]`\] : ... *extends* ... ? ... : ... : readonly `unknown`[] *extends* `T` ? `T` : `T` *extends* `UseQueryOptionsForUseQueries`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? `UseQueryOptionsForUseQueries`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : `UseQueryOptionsForUseQueries`\<`unknown`, `Error`, `unknown`, readonly ...[]\>[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseQueryOptionsForUseQueries\\]\> \}\] + \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseQueryOptionsForUseQueries\ \}\] An array with query option objects, mostly identical to `useQuery` — except that `queryClient` and `subscribed` aren't accepted per-query (`subscribed` is a top-level option here instead), and diff --git a/docs/framework/preact/reference/functions/useSuspenseQueries.md b/docs/framework/preact/reference/functions/useSuspenseQueries.md index c19d6bf748c..00648c463d2 100644 --- a/docs/framework/preact/reference/functions/useSuspenseQueries.md +++ b/docs/framework/preact/reference/functions/useSuspenseQueries.md @@ -22,7 +22,7 @@ option isn't supported, and each `query` can't have `throwOnError`, `enabled`, o #### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \} ### Parameters @@ -32,7 +32,7 @@ The `queries` array to run in Suspense, and an optional `combine` function. ##### combine? -(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}) => `TCombinedResult` +(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}) => `TCombinedResult` Use this to combine the results of the queries into a single value. The result will be structurally shared to be as referentially stable as possible. @@ -40,7 +40,7 @@ shared to be as referentially stable as possible. ##### queries \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>, `GetUseSuspenseQueryOptions`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : ...[] *extends* \[`...(...)[]`\] ? \[`...(...)[]`\] : ... *extends* ... ? ... : ... : `unknown`[] *extends* `T` ? `T` : `T` *extends* [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly ...[]\>[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryOptions\\]\> \}\] + \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryOptions\ \}\] An array with query option objects identical to `useSuspenseQuery`. @@ -292,7 +292,7 @@ option isn't supported, and each `query` can't have `throwOnError`, `enabled`, o #### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \} ### Parameters @@ -302,7 +302,7 @@ The `queries` array to run in Suspense, and an optional `combine` function. ##### combine? -(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}) => `TCombinedResult` +(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}) => `TCombinedResult` Use this to combine the results of the queries into a single value. The result will be structurally shared to be as referentially stable as possible. diff --git a/docs/framework/preact/reference/interfaces/CancelOptions.md b/docs/framework/preact/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/preact/reference/interfaces/CancelOptions.md +++ b/docs/framework/preact/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/preact/reference/interfaces/DefaultOptions.md b/docs/framework/preact/reference/interfaces/DefaultOptions.md index 7fae14fb540..9a73763ed09 100644 --- a/docs/framework/preact/reference/interfaces/DefaultOptions.md +++ b/docs/framework/preact/reference/interfaces/DefaultOptions.md @@ -15,10 +15,10 @@ Defined in: [packages/query-core/src/types.ts:1621](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | diff --git a/docs/framework/preact/reference/interfaces/DehydrateOptions.md b/docs/framework/preact/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/preact/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/preact/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/preact/reference/interfaces/DehydratedState.md b/docs/framework/preact/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/preact/reference/interfaces/DehydratedState.md +++ b/docs/framework/preact/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md b/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/preact/reference/interfaces/FetchQueryOptions.md b/docs/framework/preact/reference/interfaces/FetchQueryOptions.md index 19c4260bf7b..90e0625d587 100644 --- a/docs/framework/preact/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/preact/reference/interfaces/FocusManager.md b/docs/framework/preact/reference/interfaces/FocusManager.md index 71c585966d2..3d59e85c451 100644 --- a/docs/framework/preact/reference/interfaces/FocusManager.md +++ b/docs/framework/preact/reference/interfaces/FocusManager.md @@ -174,13 +174,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/preact/reference/interfaces/HydrateOptions.md b/docs/framework/preact/reference/interfaces/HydrateOptions.md index eccc9b8b513..30c57539b89 100644 --- a/docs/framework/preact/reference/interfaces/HydrateOptions.md +++ b/docs/framework/preact/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md b/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md index 9193c62f10e..a8917e6500f 100644 --- a/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md +++ b/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md @@ -11,7 +11,7 @@ The props accepted by `HydrationBoundary`. | Property | Type | Description | | ------ | ------ | ------ | -| `children?` | `ComponentChildren` | The components to render — always rendered unconditionally, not gated on hydration. New queries are hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it lands. | -| `options?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`HydrateOptions`](HydrateOptions.md), `"defaultOptions"`\> & `object` | Optional. Note: unlike `hydrate`, `mutations` cannot be set here. | -| `queryClient?` | [`QueryClient`](../classes/QueryClient.md) | Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. | -| `state` | [`DehydratedState`](DehydratedState.md) \| `null` \| `undefined` | The state to hydrate. | +| `children?` | `ComponentChildren` | The components to render — always rendered unconditionally, not gated on hydration. New queries are hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it lands. | +| `options?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`HydrateOptions`](HydrateOptions.md), `"defaultOptions"`\> & `object` | Optional. Note: unlike `hydrate`, `mutations` cannot be set here. | +| `queryClient?` | [`QueryClient`](../classes/QueryClient.md) | Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. | +| `state` | [`DehydratedState`](DehydratedState.md) \| `null` \| `undefined` | The state to hydrate. | diff --git a/docs/framework/preact/reference/interfaces/InfiniteData.md b/docs/framework/preact/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteData.md +++ b/docs/framework/preact/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md index d1642d98ff2..858435e5774 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md @@ -35,33 +35,33 @@ Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md index a07f20cadf8..a475eb9b048 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/preact/reference/interfaces/InitialPageParam.md b/docs/framework/preact/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/preact/reference/interfaces/InitialPageParam.md +++ b/docs/framework/preact/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/preact/reference/interfaces/InvalidateOptions.md b/docs/framework/preact/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/preact/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/preact/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/preact/reference/interfaces/MutateOptions.md b/docs/framework/preact/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/preact/reference/interfaces/MutateOptions.md +++ b/docs/framework/preact/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/preact/reference/interfaces/MutationCacheConfig.md b/docs/framework/preact/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/preact/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/preact/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/preact/reference/interfaces/MutationFilters.md b/docs/framework/preact/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/preact/reference/interfaces/MutationFilters.md +++ b/docs/framework/preact/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverOptions.md b/docs/framework/preact/reference/interfaces/MutationObserverOptions.md index 771cea89665..1920ce66911 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationOptions.md b/docs/framework/preact/reference/interfaces/MutationOptions.md index 323929c077d..9170d982368 100644 --- a/docs/framework/preact/reference/interfaces/MutationOptions.md +++ b/docs/framework/preact/reference/interfaces/MutationOptions.md @@ -31,15 +31,15 @@ Defined in: [packages/query-core/src/types.ts:1271](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | diff --git a/docs/framework/preact/reference/interfaces/MutationState.md b/docs/framework/preact/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/preact/reference/interfaces/MutationState.md +++ b/docs/framework/preact/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/preact/reference/interfaces/NotifyEvent.md b/docs/framework/preact/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/preact/reference/interfaces/NotifyEvent.md +++ b/docs/framework/preact/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/preact/reference/interfaces/OnlineManager.md b/docs/framework/preact/reference/interfaces/OnlineManager.md index 1ed3eebcf25..7e97e7bc137 100644 --- a/docs/framework/preact/reference/interfaces/OnlineManager.md +++ b/docs/framework/preact/reference/interfaces/OnlineManager.md @@ -151,13 +151,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md b/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/preact/reference/interfaces/QueryCacheConfig.md b/docs/framework/preact/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/preact/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/preact/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/preact/reference/interfaces/QueryClientConfig.md b/docs/framework/preact/reference/interfaces/QueryClientConfig.md index a314893a143..58fbbc0ffe7 100644 --- a/docs/framework/preact/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/preact/reference/interfaces/QueryClientConfig.md @@ -9,6 +9,6 @@ Defined in: [packages/query-core/src/types.ts:1609](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | -| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | -| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | +| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | +| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | diff --git a/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md b/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md index 55d2ebfa65c..bf25d55b869 100644 --- a/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md +++ b/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md @@ -11,4 +11,4 @@ The props accepted by `QueryErrorResetBoundary`. | Property | Type | Description | | ------ | ------ | ------ | -| `children` | \| `ComponentChildren` \| [`QueryErrorResetBoundaryFunction`](../type-aliases/QueryErrorResetBoundaryFunction.md) | Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. | +| `children` | \| `ComponentChildren` \| [`QueryErrorResetBoundaryFunction`](../type-aliases/QueryErrorResetBoundaryFunction.md) | Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. | diff --git a/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md b/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md index 4563e570678..49e37ad9f95 100644 --- a/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/preact/reference/interfaces/QueryFilters.md b/docs/framework/preact/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/preact/reference/interfaces/QueryFilters.md +++ b/docs/framework/preact/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverOptions.md b/docs/framework/preact/reference/interfaces/QueryObserverOptions.md index bff51c95006..f7e5be6a723 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverOptions.md @@ -44,30 +44,30 @@ Defined in: [packages/query-core/src/types.ts:432](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryOptions.md b/docs/framework/preact/reference/interfaces/QueryOptions.md index 3e4dbb3024a..966d8824818 100644 --- a/docs/framework/preact/reference/interfaces/QueryOptions.md +++ b/docs/framework/preact/reference/interfaces/QueryOptions.md @@ -31,17 +31,17 @@ Defined in: [packages/query-core/src/types.ts:276](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/preact/reference/interfaces/QueryState.md b/docs/framework/preact/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/preact/reference/interfaces/QueryState.md +++ b/docs/framework/preact/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/preact/reference/interfaces/RefetchOptions.md b/docs/framework/preact/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/preact/reference/interfaces/RefetchOptions.md +++ b/docs/framework/preact/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md b/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/preact/reference/interfaces/ResetOptions.md b/docs/framework/preact/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/preact/reference/interfaces/ResetOptions.md +++ b/docs/framework/preact/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/preact/reference/interfaces/ResultOptions.md b/docs/framework/preact/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/preact/reference/interfaces/ResultOptions.md +++ b/docs/framework/preact/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/preact/reference/interfaces/SetDataOptions.md b/docs/framework/preact/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/preact/reference/interfaces/SetDataOptions.md +++ b/docs/framework/preact/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/preact/reference/interfaces/TimeoutManager.md b/docs/framework/preact/reference/interfaces/TimeoutManager.md index 317213619d5..164487133a6 100644 --- a/docs/framework/preact/reference/interfaces/TimeoutManager.md +++ b/docs/framework/preact/reference/interfaces/TimeoutManager.md @@ -37,7 +37,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -58,7 +58,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -78,7 +80,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -99,7 +101,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -144,7 +148,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -192,7 +198,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md b/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md index 06e3eb4a7da..6290c9ce0bd 100644 --- a/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md @@ -50,31 +50,31 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md b/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md index 25110768d17..26ea7954d19 100644 --- a/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md @@ -50,33 +50,33 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/UseMutationOptions.md b/docs/framework/preact/reference/interfaces/UseMutationOptions.md index 3704bf427d0..2ebe1efa8e4 100644 --- a/docs/framework/preact/reference/interfaces/UseMutationOptions.md +++ b/docs/framework/preact/reference/interfaces/UseMutationOptions.md @@ -43,16 +43,16 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/UseQueryOptions.md b/docs/framework/preact/reference/interfaces/UseQueryOptions.md index 0325beb7917..4c746e560b6 100644 --- a/docs/framework/preact/reference/interfaces/UseQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseQueryOptions.md @@ -43,30 +43,30 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryFnData` \| () => `TQueryFnData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md b/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md index 8b2f6e24a91..22074107bc0 100644 --- a/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md @@ -50,30 +50,30 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | diff --git a/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md b/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md index 514b5c89521..298c14f1620 100644 --- a/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md @@ -44,27 +44,27 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryFnData` \| () => `TQueryFnData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | diff --git a/docs/framework/preact/reference/type-aliases/AnyDataTag.md b/docs/framework/preact/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/preact/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/preact/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index a14a716df4b..90c2d576b9d 100644 --- a/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -19,7 +19,7 @@ never `undefined` (unless a `select` changes `TData` to include `undefined`). ```ts initialData: | NonUndefinedGuard> - | () => NonUndefinedGuard> + | (() => NonUndefinedGuard>) | undefined; ``` diff --git a/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md index fd052751044..e7324462843 100644 --- a/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md @@ -19,7 +19,7 @@ The options accepted by the `queryOptions` overload selected when `initialData` ```ts initialData: | NonUndefinedGuard -| () => NonUndefinedGuard; + | (() => NonUndefinedGuard); ``` If set, this value will be used as the initial data for the query cache (as long as the query hasn't been @@ -31,7 +31,7 @@ cache. ### queryFn? ```ts -optional queryFn: QueryFunction; +optional queryFn?: QueryFunction; ``` Optional here, but omitting it is only safe when no fetch will be attempted — for example with diff --git a/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md b/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md index 5cb260a4371..6dbc2879129 100644 --- a/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | [`QueryClient`](../classes/QueryClient.md) | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/preact/reference/type-aliases/MutationScope.md b/docs/framework/preact/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/preact/reference/type-aliases/MutationScope.md +++ b/docs/framework/preact/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md index 9191c25c7d9..9b658cb5e6b 100644 --- a/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md index d35d6161a39..fc88186764a 100644 --- a/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md b/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md index 45daab83127..5a63f8dae29 100644 --- a/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md index 446bd2c42b8..7666ef4e1fd 100644 --- a/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md @@ -15,5 +15,5 @@ The props accepted by `QueryClientProvider`. | Property | Type | Description | | ------ | ------ | ------ | -| `children?` | `ComponentChildren` | The components that get access to the provided `QueryClient`. | -| `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. | +| `children?` | `ComponentChildren` | The components that get access to the provided `QueryClient`. | +| `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. | diff --git a/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md b/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md index 761e1af5402..ba9b538fa66 100644 --- a/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/preact/reference/type-aliases/ThrowOnError.md b/docs/framework/preact/reference/type-aliases/ThrowOnError.md index ffed6038ff5..40b1fcd4739 100644 --- a/docs/framework/preact/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/preact/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/preact/reference/type-aliases/TimeoutProvider.md b/docs/framework/preact/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/preact/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/preact/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index a2245f65836..1f7bf0ea4e4 100644 --- a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -17,7 +17,7 @@ may be `undefined` while the query is `pending`. ### initialData? ```ts -optional initialData: +optional initialData?: | NonUndefinedGuard> | InitialDataFunction>>; ``` diff --git a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md index 8229e0450c6..8c6ee3df79d 100644 --- a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md @@ -17,7 +17,7 @@ The options accepted by the `queryOptions` overload selected when no `initialDat ### initialData? ```ts -optional initialData: +optional initialData?: | InitialDataFunction> | NonUndefinedGuard; ``` diff --git a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md index 185d7926afc..b224eac7730 100644 --- a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md +++ b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md @@ -18,7 +18,7 @@ The options accepted by the `infiniteQueryOptions` overload selected when no `in ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If diff --git a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md index 889574a8381..300ee04f15e 100644 --- a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md @@ -17,7 +17,7 @@ not `skipToken` — same as [UndefinedInitialDataOptions](UndefinedInitialDataOp ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If diff --git a/docs/framework/preact/reference/type-aliases/Updater.md b/docs/framework/preact/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/preact/reference/type-aliases/Updater.md +++ b/docs/framework/preact/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md b/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md index cd947efe149..b70878c3b5a 100644 --- a/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md @@ -17,7 +17,7 @@ except `queryFn` is required unless a default query function has been defined. ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken>; +optional queryFn?: Exclude["queryFn"], SkipToken>; ``` `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run, diff --git a/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md b/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md index 205248982af..96e53f9652c 100644 --- a/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md @@ -17,7 +17,7 @@ is required unless a default query function has been defined. ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken>; +optional queryFn?: Exclude["queryFn"], SkipToken>; ``` `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run, diff --git a/docs/framework/preact/reference/variables/environmentManager.md b/docs/framework/preact/reference/variables/environmentManager.md index 4f88d27d2a9..1b5f65b6a99 100644 --- a/docs/framework/preact/reference/variables/environmentManager.md +++ b/docs/framework/preact/reference/variables/environmentManager.md @@ -20,7 +20,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/preact/reference/variables/notifyManager.md b/docs/framework/preact/reference/variables/notifyManager.md index c2c071b42a5..abc590e3442 100644 --- a/docs/framework/preact/reference/variables/notifyManager.md +++ b/docs/framework/preact/reference/variables/notifyManager.md @@ -13,7 +13,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -40,7 +40,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -64,7 +64,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -83,7 +83,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -112,7 +112,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -131,7 +131,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; diff --git a/docs/framework/react/reference/classes/CancelledError.md b/docs/framework/react/reference/classes/CancelledError.md index 5bd8c049574..296c3e59d58 100644 --- a/docs/framework/react/reference/classes/CancelledError.md +++ b/docs/framework/react/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### cause? ```ts -optional cause: unknown; +optional cause?: unknown; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 @@ -107,7 +107,7 @@ Error.name ### revert? ```ts -optional revert: boolean; +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) @@ -117,7 +117,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) @@ -127,7 +127,7 @@ Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/ ### stack? ```ts -optional stack: string; +optional stack?: string; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 diff --git a/docs/framework/react/reference/classes/InfiniteQueryObserver.md b/docs/framework/react/reference/classes/InfiniteQueryObserver.md index 9f45c7eefc8..85e20576a06 100644 --- a/docs/framework/react/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/react/reference/classes/InfiniteQueryObserver.md @@ -125,7 +125,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -147,13 +147,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -387,7 +381,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -397,7 +391,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -533,7 +527,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/react/reference/classes/MutationCache.md b/docs/framework/react/reference/classes/MutationCache.md index 09f705bb2e3..9d1093fd570 100644 --- a/docs/framework/react/reference/classes/MutationCache.md +++ b/docs/framework/react/reference/classes/MutationCache.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -150,7 +150,7 @@ 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) @@ -163,7 +163,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` @@ -256,13 +256,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/react/reference/classes/MutationObserver.md b/docs/framework/react/reference/classes/MutationObserver.md index d8170570502..87c7814735b 100644 --- a/docs/framework/react/reference/classes/MutationObserver.md +++ b/docs/framework/react/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/react/reference/classes/QueriesObserver.md b/docs/framework/react/reference/classes/QueriesObserver.md index b0974b01db1..d1da9a32fda 100644 --- a/docs/framework/react/reference/classes/QueriesObserver.md +++ b/docs/framework/react/reference/classes/QueriesObserver.md @@ -158,7 +158,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -265,13 +265,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/react/reference/classes/Query.md b/docs/framework/react/reference/classes/Query.md index 0d5b61737ba..c6b5f29ac9c 100644 --- a/docs/framework/react/reference/classes/Query.md +++ b/docs/framework/react/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/react/reference/classes/QueryCache.md b/docs/framework/react/reference/classes/QueryCache.md index 9af994807cf..283e6569d3c 100644 --- a/docs/framework/react/reference/classes/QueryCache.md +++ b/docs/framework/react/reference/classes/QueryCache.md @@ -34,14 +34,14 @@ 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -217,7 +217,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) ### findAll() ```ts -findAll(filters: QueryFilters): Query[]; +findAll(filters?: QueryFilters): Query[]; ``` Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) @@ -230,7 +230,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` @@ -411,13 +411,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/react/reference/classes/QueryClient.md b/docs/framework/react/reference/classes/QueryClient.md index 07b88d098aa..bdeedc74486 100644 --- a/docs/framework/react/reference/classes/QueryClient.md +++ b/docs/framework/react/reference/classes/QueryClient.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` @@ -192,7 +192,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns diff --git a/docs/framework/react/reference/classes/QueryObserver.md b/docs/framework/react/reference/classes/QueryObserver.md index 13938ce994b..a01a48e5e4e 100644 --- a/docs/framework/react/reference/classes/QueryObserver.md +++ b/docs/framework/react/reference/classes/QueryObserver.md @@ -246,7 +246,7 @@ Subscribable.hasListeners ### 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) @@ -256,7 +256,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -365,13 +365,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -433,7 +427,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/react/reference/functions/dehydrate.md b/docs/framework/react/reference/functions/dehydrate.md index 201200efdfa..4999cadaf08 100644 --- a/docs/framework/react/reference/functions/dehydrate.md +++ b/docs/framework/react/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/react/reference/functions/experimental_streamedQuery.md b/docs/framework/react/reference/functions/experimental_streamedQuery.md index e5139fc7003..cdab63c6e62 100644 --- a/docs/framework/react/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/react/reference/functions/experimental_streamedQuery.md @@ -40,45 +40,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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/react/reference/functions/keepPreviousData.md b/docs/framework/react/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/react/reference/functions/keepPreviousData.md +++ b/docs/framework/react/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/react/reference/functions/shouldThrowError.md b/docs/framework/react/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/react/reference/functions/shouldThrowError.md +++ b/docs/framework/react/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/react/reference/functions/useMutationState.md b/docs/framework/react/reference/functions/useMutationState.md index 8b4c93c0051..82c30248ee0 100644 --- a/docs/framework/react/reference/functions/useMutationState.md +++ b/docs/framework/react/reference/functions/useMutationState.md @@ -6,7 +6,7 @@ redirect_from: --- ```ts -function useMutationState(options: MutationStateOptions, queryClient?: QueryClient): TResult[]; +function useMutationState(options?: MutationStateOptions, queryClient?: QueryClient): TResult[]; ``` Defined in: [packages/react-query/src/useMutationState.ts:157](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutationState.ts#L157) @@ -27,7 +27,7 @@ state. ## Parameters -### options +### options? `MutationStateOptions`\<`TResult`, `TMutation`\> = `{}` diff --git a/docs/framework/react/reference/functions/useQueries.md b/docs/framework/react/reference/functions/useQueries.md index 61db7461507..b6c462b48c1 100644 --- a/docs/framework/react/reference/functions/useQueries.md +++ b/docs/framework/react/reference/functions/useQueries.md @@ -32,7 +32,7 @@ be structurally shared to be as referentially stable as possible. ### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \} ## Parameters @@ -40,7 +40,7 @@ be structurally shared to be as referentially stable as possible. #### combine? -(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \}) => `TCombinedResult` +(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \}) => `TCombinedResult` Use this to combine the results of the queries into a single value. The result will be structurally shared to be as referentially stable as possible. @@ -48,7 +48,7 @@ shared to be as referentially stable as possible. #### queries \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryOptionsForUseQueries`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryOptionsForUseQueries`\<`Head`\>, `GetUseQueryOptionsForUseQueries`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : readonly ...[] *extends* \[`...(...)[]`\] ? \[`...(...)[]`\] : ... *extends* ... ? ... : ... : readonly `unknown`[] *extends* `T` ? `T` : `T` *extends* `UseQueryOptionsForUseQueries`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? `UseQueryOptionsForUseQueries`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : `UseQueryOptionsForUseQueries`\<`unknown`, `Error`, `unknown`, readonly ...[]\>[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseQueryOptionsForUseQueries\\]\> \}\] + \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseQueryOptionsForUseQueries\ \}\] An array with query option objects, mostly identical to `useQuery` — except that `queryClient` and `subscribed` aren't accepted per-query (`subscribed` is a top-level option here instead), and diff --git a/docs/framework/react/reference/functions/useSuspenseQueries.md b/docs/framework/react/reference/functions/useSuspenseQueries.md index ceee7bdf046..55619fcd20b 100644 --- a/docs/framework/react/reference/functions/useSuspenseQueries.md +++ b/docs/framework/react/reference/functions/useSuspenseQueries.md @@ -24,7 +24,7 @@ option isn't supported, and each `query` can't have `throwOnError`, `enabled`, o #### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \} ### Parameters @@ -34,7 +34,7 @@ The `queries` array to run in Suspense, and an optional `combine` function. ##### combine? -(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}) => `TCombinedResult` +(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}) => `TCombinedResult` Use this to combine the results of the queries into a single value. The result will be structurally shared to be as referentially stable as possible. @@ -42,7 +42,7 @@ shared to be as referentially stable as possible. ##### queries \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>, `GetUseSuspenseQueryOptions`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : ...[] *extends* \[`...(...)[]`\] ? \[`...(...)[]`\] : ... *extends* ... ? ... : ... : `unknown`[] *extends* `T` ? `T` : `T` *extends* [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly ...[]\>[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryOptions\\]\> \}\] + \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryOptions\ \}\] An array with query option objects identical to `useSuspenseQuery`. @@ -234,7 +234,7 @@ option isn't supported, and each `query` can't have `throwOnError`, `enabled`, o #### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \} ### Parameters @@ -244,7 +244,7 @@ The `queries` array to run in Suspense, and an optional `combine` function. ##### combine? -(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\\]\> \}) => `TCombinedResult` +(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\ \}) => `TCombinedResult` Use this to combine the results of the queries into a single value. The result will be structurally shared to be as referentially stable as possible. diff --git a/docs/framework/react/reference/interfaces/CancelOptions.md b/docs/framework/react/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/react/reference/interfaces/CancelOptions.md +++ b/docs/framework/react/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/react/reference/interfaces/DefaultOptions.md b/docs/framework/react/reference/interfaces/DefaultOptions.md index 7fae14fb540..9a73763ed09 100644 --- a/docs/framework/react/reference/interfaces/DefaultOptions.md +++ b/docs/framework/react/reference/interfaces/DefaultOptions.md @@ -15,10 +15,10 @@ Defined in: [packages/query-core/src/types.ts:1621](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | diff --git a/docs/framework/react/reference/interfaces/DehydrateOptions.md b/docs/framework/react/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/react/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/react/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/react/reference/interfaces/DehydratedState.md b/docs/framework/react/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/react/reference/interfaces/DehydratedState.md +++ b/docs/framework/react/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/react/reference/interfaces/FetchNextPageOptions.md b/docs/framework/react/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/react/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/react/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/react/reference/interfaces/FetchQueryOptions.md b/docs/framework/react/reference/interfaces/FetchQueryOptions.md index 19c4260bf7b..90e0625d587 100644 --- a/docs/framework/react/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/react/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/react/reference/interfaces/FocusManager.md b/docs/framework/react/reference/interfaces/FocusManager.md index e6a52b029e0..2eb409d804b 100644 --- a/docs/framework/react/reference/interfaces/FocusManager.md +++ b/docs/framework/react/reference/interfaces/FocusManager.md @@ -177,13 +177,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/react/reference/interfaces/HydrateOptions.md b/docs/framework/react/reference/interfaces/HydrateOptions.md index eccc9b8b513..30c57539b89 100644 --- a/docs/framework/react/reference/interfaces/HydrateOptions.md +++ b/docs/framework/react/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md b/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md index 585ecddc36e..3bb2980d8cd 100644 --- a/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md +++ b/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md @@ -11,7 +11,7 @@ The props accepted by `HydrationBoundary`. | Property | Type | Description | | ------ | ------ | ------ | -| `children?` | `ReactNode` | The components to render — always rendered unconditionally, not gated on hydration. New queries are hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it lands. | -| `options?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`HydrateOptions`](HydrateOptions.md), `"defaultOptions"`\> & `object` | Optional. Note: unlike `hydrate`, `mutations` cannot be set here. | -| `queryClient?` | [`QueryClient`](../classes/QueryClient.md) | Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. | -| `state` | [`DehydratedState`](DehydratedState.md) \| `null` \| `undefined` | The state to hydrate. | +| `children?` | `ReactNode` | The components to render — always rendered unconditionally, not gated on hydration. New queries are hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it lands. | +| `options?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`HydrateOptions`](HydrateOptions.md), `"defaultOptions"`\> & `object` | Optional. Note: unlike `hydrate`, `mutations` cannot be set here. | +| `queryClient?` | [`QueryClient`](../classes/QueryClient.md) | Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. | +| `state` | [`DehydratedState`](DehydratedState.md) \| `null` \| `undefined` | The state to hydrate. | diff --git a/docs/framework/react/reference/interfaces/InfiniteData.md b/docs/framework/react/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/react/reference/interfaces/InfiniteData.md +++ b/docs/framework/react/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md index d1642d98ff2..858435e5774 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md @@ -35,33 +35,33 @@ Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md index a07f20cadf8..a475eb9b048 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/react/reference/interfaces/InitialPageParam.md b/docs/framework/react/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/react/reference/interfaces/InitialPageParam.md +++ b/docs/framework/react/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/react/reference/interfaces/InvalidateOptions.md b/docs/framework/react/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/react/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/react/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/react/reference/interfaces/MutateOptions.md b/docs/framework/react/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/react/reference/interfaces/MutateOptions.md +++ b/docs/framework/react/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/react/reference/interfaces/MutationCacheConfig.md b/docs/framework/react/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/react/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/react/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/react/reference/interfaces/MutationFilters.md b/docs/framework/react/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/react/reference/interfaces/MutationFilters.md +++ b/docs/framework/react/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverOptions.md b/docs/framework/react/reference/interfaces/MutationObserverOptions.md index 771cea89665..1920ce66911 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/react/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationOptions.md b/docs/framework/react/reference/interfaces/MutationOptions.md index 323929c077d..9170d982368 100644 --- a/docs/framework/react/reference/interfaces/MutationOptions.md +++ b/docs/framework/react/reference/interfaces/MutationOptions.md @@ -31,15 +31,15 @@ Defined in: [packages/query-core/src/types.ts:1271](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | diff --git a/docs/framework/react/reference/interfaces/MutationState.md b/docs/framework/react/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/react/reference/interfaces/MutationState.md +++ b/docs/framework/react/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/react/reference/interfaces/NotifyEvent.md b/docs/framework/react/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/react/reference/interfaces/NotifyEvent.md +++ b/docs/framework/react/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/react/reference/interfaces/OnlineManager.md b/docs/framework/react/reference/interfaces/OnlineManager.md index 88ec04f62dd..65abb535361 100644 --- a/docs/framework/react/reference/interfaces/OnlineManager.md +++ b/docs/framework/react/reference/interfaces/OnlineManager.md @@ -154,13 +154,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/react/reference/interfaces/QueriesObserverOptions.md b/docs/framework/react/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/react/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/react/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/react/reference/interfaces/QueryCacheConfig.md b/docs/framework/react/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/react/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/react/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/react/reference/interfaces/QueryClientConfig.md b/docs/framework/react/reference/interfaces/QueryClientConfig.md index a314893a143..58fbbc0ffe7 100644 --- a/docs/framework/react/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/react/reference/interfaces/QueryClientConfig.md @@ -9,6 +9,6 @@ Defined in: [packages/query-core/src/types.ts:1609](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | -| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | -| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | +| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | +| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | diff --git a/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md b/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md index 87859d9eb41..272e802e068 100644 --- a/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md +++ b/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md @@ -11,4 +11,4 @@ The props accepted by `QueryErrorResetBoundary`. | Property | Type | Description | | ------ | ------ | ------ | -| `children` | \| `ReactNode` \| [`QueryErrorResetBoundaryFunction`](../type-aliases/QueryErrorResetBoundaryFunction.md) | Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. | +| `children` | \| `ReactNode` \| [`QueryErrorResetBoundaryFunction`](../type-aliases/QueryErrorResetBoundaryFunction.md) | Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. | diff --git a/docs/framework/react/reference/interfaces/QueryExecuteOptions.md b/docs/framework/react/reference/interfaces/QueryExecuteOptions.md index 4563e570678..49e37ad9f95 100644 --- a/docs/framework/react/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/react/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/react/reference/interfaces/QueryFilters.md b/docs/framework/react/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/react/reference/interfaces/QueryFilters.md +++ b/docs/framework/react/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverOptions.md b/docs/framework/react/reference/interfaces/QueryObserverOptions.md index bff51c95006..f7e5be6a723 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/react/reference/interfaces/QueryObserverOptions.md @@ -44,30 +44,30 @@ Defined in: [packages/query-core/src/types.ts:432](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryOptions.md b/docs/framework/react/reference/interfaces/QueryOptions.md index 3e4dbb3024a..966d8824818 100644 --- a/docs/framework/react/reference/interfaces/QueryOptions.md +++ b/docs/framework/react/reference/interfaces/QueryOptions.md @@ -31,17 +31,17 @@ Defined in: [packages/query-core/src/types.ts:276](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/react/reference/interfaces/QueryState.md b/docs/framework/react/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/react/reference/interfaces/QueryState.md +++ b/docs/framework/react/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/react/reference/interfaces/RefetchOptions.md b/docs/framework/react/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/react/reference/interfaces/RefetchOptions.md +++ b/docs/framework/react/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/react/reference/interfaces/RefetchQueryFilters.md b/docs/framework/react/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/react/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/react/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/react/reference/interfaces/ResetOptions.md b/docs/framework/react/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/react/reference/interfaces/ResetOptions.md +++ b/docs/framework/react/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/react/reference/interfaces/ResultOptions.md b/docs/framework/react/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/react/reference/interfaces/ResultOptions.md +++ b/docs/framework/react/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/react/reference/interfaces/SetDataOptions.md b/docs/framework/react/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/react/reference/interfaces/SetDataOptions.md +++ b/docs/framework/react/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/react/reference/interfaces/TimeoutManager.md b/docs/framework/react/reference/interfaces/TimeoutManager.md index b0f0a4fb8f5..b6971209e15 100644 --- a/docs/framework/react/reference/interfaces/TimeoutManager.md +++ b/docs/framework/react/reference/interfaces/TimeoutManager.md @@ -39,7 +39,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -60,7 +60,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -80,7 +82,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -101,7 +103,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -146,7 +150,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -194,7 +200,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md b/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md index d54f27af632..def96c0d62c 100644 --- a/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md @@ -50,31 +50,31 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md b/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md index 8f9eed9aa36..762f651d129 100644 --- a/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md @@ -50,33 +50,33 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/UseMutationOptions.md b/docs/framework/react/reference/interfaces/UseMutationOptions.md index e0728cb188a..dfb33f7e7c4 100644 --- a/docs/framework/react/reference/interfaces/UseMutationOptions.md +++ b/docs/framework/react/reference/interfaces/UseMutationOptions.md @@ -43,16 +43,16 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/UseQueryOptions.md b/docs/framework/react/reference/interfaces/UseQueryOptions.md index 432261c83e8..50ff9ed04b6 100644 --- a/docs/framework/react/reference/interfaces/UseQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseQueryOptions.md @@ -43,30 +43,30 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryFnData` \| () => `TQueryFnData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md b/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md index baebb01ff51..597f1c28ac2 100644 --- a/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md @@ -50,30 +50,30 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | diff --git a/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md b/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md index 9b4ff26b411..82eeb196569 100644 --- a/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md @@ -44,27 +44,27 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryFnData` \| () => `TQueryFnData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `subscribed?` | `boolean` | `true` | Set this to `false` to unsubscribe this observer from updates to the query cache. | diff --git a/docs/framework/react/reference/type-aliases/AnyDataTag.md b/docs/framework/react/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/react/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/react/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index 4e7b21eb1fb..d99f0f298cd 100644 --- a/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -19,7 +19,7 @@ never `undefined` (unless a `select` changes `TData` to include `undefined`). ```ts initialData: | NonUndefinedGuard> - | () => NonUndefinedGuard> + | (() => NonUndefinedGuard>) | undefined; ``` diff --git a/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md index cce85687c98..280176add04 100644 --- a/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md @@ -19,7 +19,7 @@ The options accepted by the `queryOptions` overload selected when `initialData` ```ts initialData: | NonUndefinedGuard -| () => NonUndefinedGuard; + | (() => NonUndefinedGuard); ``` If set, this value will be used as the initial data for the query cache (as long as the query hasn't been @@ -31,7 +31,7 @@ cache. ### queryFn? ```ts -optional queryFn: QueryFunction; +optional queryFn?: QueryFunction; ``` Optional here, but omitting it is only safe when no fetch will be attempted — for example with diff --git a/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/react/reference/type-aliases/MutationFunctionContext.md b/docs/framework/react/reference/type-aliases/MutationFunctionContext.md index 5cb260a4371..6dbc2879129 100644 --- a/docs/framework/react/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/react/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | [`QueryClient`](../classes/QueryClient.md) | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/react/reference/type-aliases/MutationScope.md b/docs/framework/react/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/react/reference/type-aliases/MutationScope.md +++ b/docs/framework/react/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md index 9191c25c7d9..9b658cb5e6b 100644 --- a/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md index d35d6161a39..fc88186764a 100644 --- a/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/react/reference/type-aliases/QueryBooleanOption.md b/docs/framework/react/reference/type-aliases/QueryBooleanOption.md index 45daab83127..5a63f8dae29 100644 --- a/docs/framework/react/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/react/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md index 8ed0a3bd4da..f63ac888d96 100644 --- a/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md @@ -15,5 +15,5 @@ The props accepted by `QueryClientProvider`. | Property | Type | Description | | ------ | ------ | ------ | -| `children?` | `React.ReactNode` | The components that get access to the provided `QueryClient`. | -| `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. | +| `children?` | `React.ReactNode` | The components that get access to the provided `QueryClient`. | +| `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. | diff --git a/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/react/reference/type-aliases/StaleTimeFunction.md b/docs/framework/react/reference/type-aliases/StaleTimeFunction.md index 761e1af5402..ba9b538fa66 100644 --- a/docs/framework/react/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/react/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/react/reference/type-aliases/ThrowOnError.md b/docs/framework/react/reference/type-aliases/ThrowOnError.md index ffed6038ff5..40b1fcd4739 100644 --- a/docs/framework/react/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/react/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/react/reference/type-aliases/TimeoutProvider.md b/docs/framework/react/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/react/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/react/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index de486a2b72d..51a5b3048bd 100644 --- a/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -17,7 +17,7 @@ may be `undefined` while the query is `pending`. ### initialData? ```ts -optional initialData: +optional initialData?: | NonUndefinedGuard> | InitialDataFunction>>; ``` diff --git a/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md index bf9de58ac2d..3adb38b1067 100644 --- a/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md @@ -17,7 +17,7 @@ The options accepted by the `queryOptions` overload selected when no `initialDat ### initialData? ```ts -optional initialData: +optional initialData?: | InitialDataFunction> | NonUndefinedGuard; ``` diff --git a/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md b/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md index 1d098ea74fc..caeb84825ae 100644 --- a/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md +++ b/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md @@ -18,7 +18,7 @@ The options accepted by the `infiniteQueryOptions` overload selected when no `in ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If diff --git a/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md index 0a7365b2ffa..c12fda9108f 100644 --- a/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md @@ -17,7 +17,7 @@ not `skipToken` — same as [UndefinedInitialDataOptions](UndefinedInitialDataOp ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken | undefined>; +optional queryFn?: Exclude["queryFn"], SkipToken | undefined>; ``` `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If diff --git a/docs/framework/react/reference/type-aliases/Updater.md b/docs/framework/react/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/react/reference/type-aliases/Updater.md +++ b/docs/framework/react/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md b/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md index cddee068a8d..4efd8192092 100644 --- a/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md @@ -17,7 +17,7 @@ except `queryFn` is required unless a default query function has been defined. ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken>; +optional queryFn?: Exclude["queryFn"], SkipToken>; ``` `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run, diff --git a/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md b/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md index ccf272bb395..cac8aa2ab4a 100644 --- a/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md @@ -17,7 +17,7 @@ is required unless a default query function has been defined. ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken>; +optional queryFn?: Exclude["queryFn"], SkipToken>; ``` `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run, diff --git a/docs/framework/react/reference/variables/environmentManager.md b/docs/framework/react/reference/variables/environmentManager.md index 55662e3949f..a0d0c5333f2 100644 --- a/docs/framework/react/reference/variables/environmentManager.md +++ b/docs/framework/react/reference/variables/environmentManager.md @@ -22,7 +22,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/react/reference/variables/notifyManager.md b/docs/framework/react/reference/variables/notifyManager.md index 81f8c2e5d54..98c410ba027 100644 --- a/docs/framework/react/reference/variables/notifyManager.md +++ b/docs/framework/react/reference/variables/notifyManager.md @@ -16,7 +16,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -43,7 +43,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -67,7 +67,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -86,7 +86,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -115,7 +115,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -134,7 +134,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; diff --git a/docs/framework/solid/reference/classes/CancelledError.md b/docs/framework/solid/reference/classes/CancelledError.md index 5bd8c049574..296c3e59d58 100644 --- a/docs/framework/solid/reference/classes/CancelledError.md +++ b/docs/framework/solid/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### cause? ```ts -optional cause: unknown; +optional cause?: unknown; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 @@ -107,7 +107,7 @@ Error.name ### revert? ```ts -optional revert: boolean; +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) @@ -117,7 +117,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) @@ -127,7 +127,7 @@ Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/ ### stack? ```ts -optional stack: string; +optional stack?: string; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 diff --git a/docs/framework/solid/reference/classes/InfiniteQueryObserver.md b/docs/framework/solid/reference/classes/InfiniteQueryObserver.md index 4809c2eca36..e5c47cfae87 100644 --- a/docs/framework/solid/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/solid/reference/classes/InfiniteQueryObserver.md @@ -122,7 +122,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -144,13 +144,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -384,7 +378,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -394,7 +388,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -530,7 +524,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/solid/reference/classes/MutationCache.md b/docs/framework/solid/reference/classes/MutationCache.md index b9d3b847527..4b8f85cab33 100644 --- a/docs/framework/solid/reference/classes/MutationCache.md +++ b/docs/framework/solid/reference/classes/MutationCache.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -147,7 +147,7 @@ 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) @@ -160,7 +160,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` @@ -253,13 +253,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/solid/reference/classes/MutationObserver.md b/docs/framework/solid/reference/classes/MutationObserver.md index f6ab38a37df..cdb0fbe8ac1 100644 --- a/docs/framework/solid/reference/classes/MutationObserver.md +++ b/docs/framework/solid/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/solid/reference/classes/QueriesObserver.md b/docs/framework/solid/reference/classes/QueriesObserver.md index a9e663f9a6d..3a07c7a44d8 100644 --- a/docs/framework/solid/reference/classes/QueriesObserver.md +++ b/docs/framework/solid/reference/classes/QueriesObserver.md @@ -155,7 +155,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -262,13 +262,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/solid/reference/classes/Query.md b/docs/framework/solid/reference/classes/Query.md index 7cba080a4b4..30b20ec99a2 100644 --- a/docs/framework/solid/reference/classes/Query.md +++ b/docs/framework/solid/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/solid/reference/classes/QueryCache.md b/docs/framework/solid/reference/classes/QueryCache.md index 800a96ea70b..20f8773d189 100644 --- a/docs/framework/solid/reference/classes/QueryCache.md +++ b/docs/framework/solid/reference/classes/QueryCache.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -214,7 +214,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) ### findAll() ```ts -findAll(filters: QueryFilters): Query[]; +findAll(filters?: QueryFilters): Query[]; ``` Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) @@ -227,7 +227,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` @@ -408,13 +408,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/solid/reference/classes/QueryClient.md b/docs/framework/solid/reference/classes/QueryClient.md index 80b07c841a0..5e62f97ea61 100644 --- a/docs/framework/solid/reference/classes/QueryClient.md +++ b/docs/framework/solid/reference/classes/QueryClient.md @@ -17,14 +17,14 @@ The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.quer ### Constructor ```ts -new QueryClient(config: QueryClientConfig): QueryClient; +new QueryClient(config?: QueryClientConfig): QueryClient; ``` Defined in: [packages/solid-query/src/QueryClient.ts:110](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L110) #### Parameters -##### config +##### config? [`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` @@ -202,7 +202,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns diff --git a/docs/framework/solid/reference/classes/QueryObserver.md b/docs/framework/solid/reference/classes/QueryObserver.md index 6e309140afa..e1cf5882f45 100644 --- a/docs/framework/solid/reference/classes/QueryObserver.md +++ b/docs/framework/solid/reference/classes/QueryObserver.md @@ -243,7 +243,7 @@ Subscribable.hasListeners ### 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) @@ -253,7 +253,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -362,13 +362,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -430,7 +424,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/solid/reference/functions/dehydrate.md b/docs/framework/solid/reference/functions/dehydrate.md index 782758a4380..78d9ea88531 100644 --- a/docs/framework/solid/reference/functions/dehydrate.md +++ b/docs/framework/solid/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul `QueryClient` -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/solid/reference/functions/experimental_streamedQuery.md b/docs/framework/solid/reference/functions/experimental_streamedQuery.md index 0318cf7c16a..791a80817f2 100644 --- a/docs/framework/solid/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/solid/reference/functions/experimental_streamedQuery.md @@ -38,45 +38,7 @@ The function that returns an AsyncIterable to stream data from. ## Returns -```ts -(context: object): TData | Promise; -``` - -### Parameters - -#### context - -##### client - -`QueryClient` - -##### 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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/solid/reference/functions/keepPreviousData.md b/docs/framework/solid/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/solid/reference/functions/keepPreviousData.md +++ b/docs/framework/solid/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/solid/reference/functions/shouldThrowError.md b/docs/framework/solid/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/solid/reference/functions/shouldThrowError.md +++ b/docs/framework/solid/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/solid/reference/functions/useMutationState.md b/docs/framework/solid/reference/functions/useMutationState.md index b89c513cdf2..43bdf1bc454 100644 --- a/docs/framework/solid/reference/functions/useMutationState.md +++ b/docs/framework/solid/reference/functions/useMutationState.md @@ -6,7 +6,7 @@ redirect_from: --- ```ts -function useMutationState(options: Accessor>, queryClient?: Accessor): Accessor; +function useMutationState(options?: Accessor>, queryClient?: Accessor): Accessor; ``` Defined in: [packages/solid-query/src/useMutationState.ts:124](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useMutationState.ts#L124) @@ -27,7 +27,7 @@ state. ## Parameters -### options +### options? `Accessor`\<`MutationStateOptions`\<`TResult`, `TMutation`\>\> = `...` diff --git a/docs/framework/solid/reference/functions/useQueries.md b/docs/framework/solid/reference/functions/useQueries.md index 4dfdf4fce69..6e5b92e94e6 100644 --- a/docs/framework/solid/reference/functions/useQueries.md +++ b/docs/framework/solid/reference/functions/useQueries.md @@ -7,9 +7,9 @@ redirect_from: ```ts function useQueries(queriesOptions: Accessor<{ - combine?: (result: T extends [] ? [] : T extends [Head] ? [GetResults] : T extends [Head, ...Tail[]] ? [...Tail[]] extends [] ? [] : [...Tail[]] extends [Head] ? [GetResults<...>, GetResults<...>] : [...(...)[]] extends [..., ...(...)[]] ? ... extends ... ? ... : ... : [...(...)[]] : { [K in string | number | symbol]: GetResults]> }) => TCombinedResult; + combine?: (result: T extends [] ? [] : T extends [Head] ? [GetResults] : T extends [Head, ...Tail[]] ? [...Tail[]] extends [] ? [] : [...Tail[]] extends [Head] ? [GetResults<...>, GetResults<...>] : [...(...)[]] extends [..., ...(...)[]] ? ... extends ... ? ... : ... : [...(...)[]] : { [K in string | number | symbol]: GetResults }) => TCombinedResult; queries: | readonly [T extends [] ? [] : T extends [Head] ? [GetOptions] : T extends [Head, ...Tail[]] ? [...Tail[]] extends [] ? [] : [...Tail[]] extends [Head] ? [GetOptions<...>, GetOptions<...>] : [...(...)[]] extends [..., ...(...)[]] ? ... extends ... ? ... : ... : ... extends ... ? ... : ... : readonly unknown[] extends T ? T : T extends UseQueryOptionsForUseQueries<..., ..., ..., ...>[] ? UseQueryOptionsForUseQueries<..., ..., ..., ...>[] : UseQueryOptionsForUseQueries<..., ..., ..., ...>[]] - | readonly [{ [K in string | number | symbol]: GetOptions]> }]; + | readonly [{ [K in string | number | symbol]: GetOptions }]; }>, queryClient?: Accessor): TCombinedResult; ``` @@ -66,16 +66,16 @@ previously rendered queries, because the number of queries can differ between re \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `unknown`\> \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `unknown`\> \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `unknown`\> - \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \} + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\ \} ## Parameters ### queriesOptions `Accessor`\<\{ - `combine?`: (`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<...\>, `GetResults`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \}) => `TCombinedResult`; + `combine?`: (`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<...\>, `GetResults`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \{ \[K in string \| number \| symbol\]: GetResults\ \}) => `TCombinedResult`; `queries`: \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetOptions`\<...\>, `GetOptions`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : ... *extends* ... ? ... : ... : readonly `unknown`[] *extends* `T` ? `T` : `T` *extends* `UseQueryOptionsForUseQueries`\<..., ..., ..., ...\>[] ? `UseQueryOptionsForUseQueries`\<..., ..., ..., ...\>[] : `UseQueryOptionsForUseQueries`\<..., ..., ..., ...\>[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetOptions\\]\> \}\]; + \| readonly \[\{ \[K in string \| number \| symbol\]: GetOptions\ \}\]; \}\> An accessor returning the `queries` array to run, and an optional `combine` diff --git a/docs/framework/solid/reference/interfaces/CancelOptions.md b/docs/framework/solid/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/solid/reference/interfaces/CancelOptions.md +++ b/docs/framework/solid/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/solid/reference/interfaces/DefaultOptions.md b/docs/framework/solid/reference/interfaces/DefaultOptions.md index ac3e170bc04..276d05e95ad 100644 --- a/docs/framework/solid/reference/interfaces/DefaultOptions.md +++ b/docs/framework/solid/reference/interfaces/DefaultOptions.md @@ -24,10 +24,10 @@ The default type of errors thrown by queries and mutations using this `QueryClie | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | - | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | - | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | - | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | - | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | - | | `hydrate.mutations?` | `MutationOptions`\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | - | | `hydrate.queries?` | `QueryOptions`\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | - | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | - | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"`\> | Default options applied to every query, unless overridden per-query. | `CoreDefaultOptions.queries` | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | - | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"`\> | Default options applied to every query, unless overridden per-query. | `CoreDefaultOptions.queries` | diff --git a/docs/framework/solid/reference/interfaces/DehydrateOptions.md b/docs/framework/solid/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/solid/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/solid/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/solid/reference/interfaces/DehydratedState.md b/docs/framework/solid/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/solid/reference/interfaces/DehydratedState.md +++ b/docs/framework/solid/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md b/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/solid/reference/interfaces/FetchQueryOptions.md b/docs/framework/solid/reference/interfaces/FetchQueryOptions.md index acafe171c1d..39161409b85 100644 --- a/docs/framework/solid/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/solid/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/solid/reference/interfaces/FocusManager.md b/docs/framework/solid/reference/interfaces/FocusManager.md index 71c585966d2..3d59e85c451 100644 --- a/docs/framework/solid/reference/interfaces/FocusManager.md +++ b/docs/framework/solid/reference/interfaces/FocusManager.md @@ -174,13 +174,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/solid/reference/interfaces/HydrateOptions.md b/docs/framework/solid/reference/interfaces/HydrateOptions.md index 5d60315e073..3a628fc67e4 100644 --- a/docs/framework/solid/reference/interfaces/HydrateOptions.md +++ b/docs/framework/solid/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | `MutationOptions`\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | `QueryOptions`\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/solid/reference/interfaces/InfiniteData.md b/docs/framework/solid/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteData.md +++ b/docs/framework/solid/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md index 317d49e2da1..fde6009eb90 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md @@ -47,33 +47,33 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `reconcile?` | \| `string` \| `false` \| (`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData` | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `reconcile?` | \| `string` \| `false` \| ((`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData`) | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md b/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md index c6313088e05..0120996c735 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md @@ -47,34 +47,34 @@ The type of the parameter passed to `queryFn` to fetch a given page. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `deferStream?` | `boolean` | `false` | Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. This can be useful to avoid sending a loading state to the client before the query has resolved. | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` | `undefined` | The query key to use for this query. Required here, unlike on the options this type extends. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/solid/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `reconcile?` | \| `string` \| `false` \| (`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData` | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| ~~`suspense?`~~ | `boolean` | `undefined` | **Deprecated** The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useInfiniteQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `deferStream?` | `boolean` | `false` | Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. This can be useful to avoid sending a loading state to the client before the query has resolved. | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` | `undefined` | The query key to use for this query. Required here, unlike on the options this type extends. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/solid/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `reconcile?` | \| `string` \| `false` \| ((`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData`) | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| ~~`suspense?`~~ | `boolean` | `undefined` | **Deprecated** The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useInfiniteQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md index 4033d0c650a..4082a02cd9c 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -23,6 +23,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/solid/reference/interfaces/InitialPageParam.md b/docs/framework/solid/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/solid/reference/interfaces/InitialPageParam.md +++ b/docs/framework/solid/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/solid/reference/interfaces/InvalidateOptions.md b/docs/framework/solid/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/solid/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/solid/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/solid/reference/interfaces/MutateOptions.md b/docs/framework/solid/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/solid/reference/interfaces/MutateOptions.md +++ b/docs/framework/solid/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/solid/reference/interfaces/MutationCacheConfig.md b/docs/framework/solid/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/solid/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/solid/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/solid/reference/interfaces/MutationFilters.md b/docs/framework/solid/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/solid/reference/interfaces/MutationFilters.md +++ b/docs/framework/solid/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverOptions.md b/docs/framework/solid/reference/interfaces/MutationObserverOptions.md index fb80b0f7eca..04926f83af4 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationOptions.md b/docs/framework/solid/reference/interfaces/MutationOptions.md index a1cdd9c7048..da3d26a4b8a 100644 --- a/docs/framework/solid/reference/interfaces/MutationOptions.md +++ b/docs/framework/solid/reference/interfaces/MutationOptions.md @@ -41,16 +41,16 @@ The type returned by `onMutate`, passed on to `onSuccess`/`onError`/`onSettled`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/solid/reference/interfaces/MutationState.md b/docs/framework/solid/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/solid/reference/interfaces/MutationState.md +++ b/docs/framework/solid/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/solid/reference/interfaces/NotifyEvent.md b/docs/framework/solid/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/solid/reference/interfaces/NotifyEvent.md +++ b/docs/framework/solid/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/solid/reference/interfaces/OnlineManager.md b/docs/framework/solid/reference/interfaces/OnlineManager.md index 1ed3eebcf25..7e97e7bc137 100644 --- a/docs/framework/solid/reference/interfaces/OnlineManager.md +++ b/docs/framework/solid/reference/interfaces/OnlineManager.md @@ -151,13 +151,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md b/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/solid/reference/interfaces/QueryCacheConfig.md b/docs/framework/solid/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/solid/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/solid/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/solid/reference/interfaces/QueryClientConfig.md b/docs/framework/solid/reference/interfaces/QueryClientConfig.md index 133bd3225ff..272403d7f12 100644 --- a/docs/framework/solid/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/solid/reference/interfaces/QueryClientConfig.md @@ -15,6 +15,6 @@ The config accepted by `new QueryClient(config)`, with Solid's extended [Default | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | `QueryCoreClientConfig.defaultOptions` | -| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | - | -| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | - | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | `QueryCoreClientConfig.defaultOptions` | +| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | - | +| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | - | diff --git a/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md b/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md index 37ce506b6e5..18b5f4c4102 100644 --- a/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/solid/reference/interfaces/QueryFilters.md b/docs/framework/solid/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/solid/reference/interfaces/QueryFilters.md +++ b/docs/framework/solid/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverOptions.md b/docs/framework/solid/reference/interfaces/QueryObserverOptions.md index 55bc9d5b086..bfbca9c7965 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverOptions.md @@ -54,30 +54,30 @@ is shared with an infinite query's observer options. Defaults to `never` for reg | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `reconcile?` | \| `string` \| `false` \| (`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData` | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `reconcile?` | \| `string` \| `false` \| ((`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData`) | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryOptions.md b/docs/framework/solid/reference/interfaces/QueryOptions.md index 69c6dbac639..78c8a32842c 100644 --- a/docs/framework/solid/reference/interfaces/QueryOptions.md +++ b/docs/framework/solid/reference/interfaces/QueryOptions.md @@ -42,31 +42,31 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `deferStream?` | `boolean` | `false` | Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. This can be useful to avoid sending a loading state to the client before the query has resolved. | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryFnData` \| () => `TQueryFnData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `reconcile?` | \| `string` \| `false` \| (`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData` | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| ~~`suspense?`~~ | `boolean` | `undefined` | **Deprecated** The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `deferStream?` | `boolean` | `false` | Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. This can be useful to avoid sending a loading state to the client before the query has resolved. | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `reconcile?` | \| `string` \| `false` \| ((`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData`) | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| ~~`suspense?`~~ | `boolean` | `undefined` | **Deprecated** The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/solid/reference/interfaces/QueryState.md b/docs/framework/solid/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/solid/reference/interfaces/QueryState.md +++ b/docs/framework/solid/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/solid/reference/interfaces/RefetchOptions.md b/docs/framework/solid/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/solid/reference/interfaces/RefetchOptions.md +++ b/docs/framework/solid/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md b/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/solid/reference/interfaces/ResetOptions.md b/docs/framework/solid/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/solid/reference/interfaces/ResetOptions.md +++ b/docs/framework/solid/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/solid/reference/interfaces/ResultOptions.md b/docs/framework/solid/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/solid/reference/interfaces/ResultOptions.md +++ b/docs/framework/solid/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/solid/reference/interfaces/SetDataOptions.md b/docs/framework/solid/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/solid/reference/interfaces/SetDataOptions.md +++ b/docs/framework/solid/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/solid/reference/interfaces/TimeoutManager.md b/docs/framework/solid/reference/interfaces/TimeoutManager.md index 317213619d5..164487133a6 100644 --- a/docs/framework/solid/reference/interfaces/TimeoutManager.md +++ b/docs/framework/solid/reference/interfaces/TimeoutManager.md @@ -37,7 +37,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -58,7 +58,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -78,7 +80,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -99,7 +101,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -144,7 +148,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -192,7 +198,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md b/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md index d34c391f5c5..81ec13dbea5 100644 --- a/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md +++ b/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md @@ -54,31 +54,31 @@ The type of your `queryKey`. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `deferStream?` | `boolean` | `false` | Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. This can be useful to avoid sending a loading state to the client before the query has resolved. | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `reconcile?` | \| `string` \| `false` \| (`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData` | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| ~~`suspense?`~~ | `boolean` | `undefined` | **Deprecated** The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `deferStream?` | `boolean` | `false` | Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. This can be useful to avoid sending a loading state to the client before the query has resolved. | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `reconcile?` | \| `string` \| `false` \| ((`oldData`: `TData` \| `undefined`, `newData`: `TData`) => `TData`) | `undefined` | Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| ~~`suspense?`~~ | `boolean` | `undefined` | **Deprecated** The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/solid/reference/type-aliases/AnyDataTag.md b/docs/framework/solid/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/solid/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/solid/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md b/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md index be626e866be..be4bb7c20a0 100644 --- a/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | `QueryClient` | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | `QueryClient` | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/solid/reference/type-aliases/MutationScope.md b/docs/framework/solid/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/solid/reference/type-aliases/MutationScope.md +++ b/docs/framework/solid/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md index 9191c25c7d9..9b658cb5e6b 100644 --- a/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md index d35d6161a39..fc88186764a 100644 --- a/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md b/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md index 45daab83127..5a63f8dae29 100644 --- a/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md index 47a1afc64b1..51cc0021169 100644 --- a/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md @@ -15,5 +15,5 @@ The props accepted by `QueryClientProvider`. | Property | Type | Description | | ------ | ------ | ------ | -| `children?` | `JSX.Element` | The components that get access to the provided `QueryClient`. | -| `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. | +| `children?` | `JSX.Element` | The components that get access to the provided `QueryClient`. | +| `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. | diff --git a/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md b/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md index 761e1af5402..ba9b538fa66 100644 --- a/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/solid/reference/type-aliases/ThrowOnError.md b/docs/framework/solid/reference/type-aliases/ThrowOnError.md index ffed6038ff5..40b1fcd4739 100644 --- a/docs/framework/solid/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/solid/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/solid/reference/type-aliases/TimeoutProvider.md b/docs/framework/solid/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/solid/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/solid/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/solid/reference/type-aliases/Updater.md b/docs/framework/solid/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/solid/reference/type-aliases/Updater.md +++ b/docs/framework/solid/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/solid/reference/variables/QueryClientContext.md b/docs/framework/solid/reference/variables/QueryClientContext.md index 531b7630c2d..dbc214350a0 100644 --- a/docs/framework/solid/reference/variables/QueryClientContext.md +++ b/docs/framework/solid/reference/variables/QueryClientContext.md @@ -4,7 +4,7 @@ title: QueryClientContext --- ```ts -const QueryClientContext: Context<() => QueryClient | undefined>; +const QueryClientContext: Context<(() => QueryClient) | undefined>; ``` Defined in: [packages/solid-query/src/QueryClientProvider.tsx:13](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L13) diff --git a/docs/framework/solid/reference/variables/createQueries.md b/docs/framework/solid/reference/variables/createQueries.md index 0af56245ad5..3ea3d7ebb68 100644 --- a/docs/framework/solid/reference/variables/createQueries.md +++ b/docs/framework/solid/reference/variables/createQueries.md @@ -7,7 +7,7 @@ title: createQueries const createQueries: (queriesOptions: Accessor<{ combine?: (result: T extends [] ? [] : T extends [Head] ? [GetResults] : T extends [Head, ...Tail[]] ? [...Tail[]] extends [] ? [] : [...(...)[]] extends [...] ? [..., ...] : ... extends ... ? ... : ... : { [K in string | number | symbol]: GetResults<(...)[(...)]> }) => TCombinedResult; queries: | readonly [T extends [] ? [] : T extends [Head] ? [GetOptions] : T extends [Head, ...Tail[]] ? [...Tail[]] extends [] ? [] : [...(...)[]] extends [...] ? [..., ...] : ... extends ... ? ... : ... : readonly unknown[] extends T ? T : T extends ...[] ? ...[] : ...[]] - | readonly [{ [K in string | number | symbol]: GetOptions]> }]; + | readonly [{ [K in string | number | symbol]: GetOptions }]; }>, queryClient?: Accessor) => TCombinedResult = useQueries; ``` @@ -64,7 +64,7 @@ previously rendered queries, because the number of queries can differ between re \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `unknown`\> \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `unknown`\> \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `unknown`\> - \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<...\>, `GetResults`\<...\>, `GetResults`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\<(...)\[(...)\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \} + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<...\>, `GetResults`\<...\>, `GetResults`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\<(...)\[(...)\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\ \} ## Parameters @@ -73,7 +73,7 @@ previously rendered queries, because the number of queries can differ between re `Accessor`\<\{ `combine?`: (`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...(...)[]`\] *extends* \[...\] ? \[..., ...\] : ... *extends* ... ? ... : ... : \{ \[K in string \| number \| symbol\]: GetResults\<(...)\[(...)\]\> \}) => `TCombinedResult`; `queries`: \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...(...)[]`\] *extends* \[...\] ? \[..., ...\] : ... *extends* ... ? ... : ... : readonly `unknown`[] *extends* `T` ? `T` : `T` *extends* ...[] ? ...[] : ...[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetOptions\\]\> \}\]; + \| readonly \[\{ \[K in string \| number \| symbol\]: GetOptions\ \}\]; \}\> An accessor returning the `queries` array to run, and an optional `combine` diff --git a/docs/framework/solid/reference/variables/environmentManager.md b/docs/framework/solid/reference/variables/environmentManager.md index 4f88d27d2a9..1b5f65b6a99 100644 --- a/docs/framework/solid/reference/variables/environmentManager.md +++ b/docs/framework/solid/reference/variables/environmentManager.md @@ -20,7 +20,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/solid/reference/variables/notifyManager.md b/docs/framework/solid/reference/variables/notifyManager.md index c2c071b42a5..abc590e3442 100644 --- a/docs/framework/solid/reference/variables/notifyManager.md +++ b/docs/framework/solid/reference/variables/notifyManager.md @@ -13,7 +13,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -40,7 +40,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -64,7 +64,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -83,7 +83,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -112,7 +112,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -131,7 +131,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; diff --git a/docs/framework/svelte/reference/classes/CancelledError.md b/docs/framework/svelte/reference/classes/CancelledError.md index 5bd8c049574..296c3e59d58 100644 --- a/docs/framework/svelte/reference/classes/CancelledError.md +++ b/docs/framework/svelte/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### cause? ```ts -optional cause: unknown; +optional cause?: unknown; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 @@ -107,7 +107,7 @@ Error.name ### revert? ```ts -optional revert: boolean; +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) @@ -117,7 +117,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) @@ -127,7 +127,7 @@ Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/ ### stack? ```ts -optional stack: string; +optional stack?: string; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 diff --git a/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md b/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md index e4c49d4aad8..1a70c8ebf7f 100644 --- a/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md @@ -122,7 +122,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -144,13 +144,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -384,7 +378,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -394,7 +388,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -530,7 +524,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/svelte/reference/classes/MutationCache.md b/docs/framework/svelte/reference/classes/MutationCache.md index b9d3b847527..4b8f85cab33 100644 --- a/docs/framework/svelte/reference/classes/MutationCache.md +++ b/docs/framework/svelte/reference/classes/MutationCache.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -147,7 +147,7 @@ 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) @@ -160,7 +160,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` @@ -253,13 +253,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/MutationObserver.md b/docs/framework/svelte/reference/classes/MutationObserver.md index d8170570502..87c7814735b 100644 --- a/docs/framework/svelte/reference/classes/MutationObserver.md +++ b/docs/framework/svelte/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/QueriesObserver.md b/docs/framework/svelte/reference/classes/QueriesObserver.md index ae3ccad54da..08c997c2d13 100644 --- a/docs/framework/svelte/reference/classes/QueriesObserver.md +++ b/docs/framework/svelte/reference/classes/QueriesObserver.md @@ -155,7 +155,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -262,13 +262,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/Query.md b/docs/framework/svelte/reference/classes/Query.md index 0d5b61737ba..c6b5f29ac9c 100644 --- a/docs/framework/svelte/reference/classes/Query.md +++ b/docs/framework/svelte/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/svelte/reference/classes/QueryCache.md b/docs/framework/svelte/reference/classes/QueryCache.md index f6fcffd0a62..b29348f1a4b 100644 --- a/docs/framework/svelte/reference/classes/QueryCache.md +++ b/docs/framework/svelte/reference/classes/QueryCache.md @@ -31,14 +31,14 @@ 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -214,7 +214,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) ### findAll() ```ts -findAll(filters: QueryFilters): Query[]; +findAll(filters?: QueryFilters): Query[]; ``` Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) @@ -227,7 +227,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` @@ -408,13 +408,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/QueryClient.md b/docs/framework/svelte/reference/classes/QueryClient.md index 1dcf71fbffb..07781860817 100644 --- a/docs/framework/svelte/reference/classes/QueryClient.md +++ b/docs/framework/svelte/reference/classes/QueryClient.md @@ -28,14 +28,14 @@ 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) #### Parameters -##### config +##### config? [`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` @@ -189,7 +189,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns diff --git a/docs/framework/svelte/reference/classes/QueryObserver.md b/docs/framework/svelte/reference/classes/QueryObserver.md index 553457e08df..845acfe60cb 100644 --- a/docs/framework/svelte/reference/classes/QueryObserver.md +++ b/docs/framework/svelte/reference/classes/QueryObserver.md @@ -243,7 +243,7 @@ Subscribable.hasListeners ### 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) @@ -253,7 +253,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -362,13 +362,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -430,7 +424,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/svelte/reference/functions/createQueries.md b/docs/framework/svelte/reference/functions/createQueries.md index 56546e5a580..5bbf011efb2 100644 --- a/docs/framework/svelte/reference/functions/createQueries.md +++ b/docs/framework/svelte/reference/functions/createQueries.md @@ -5,9 +5,9 @@ title: createQueries ```ts function createQueries(createQueriesOptions: Accessor<{ - combine?: (result: T extends [] ? [] : T extends [Head] ? [GetCreateQueryResult] : T extends [Head, ...Tails[]] ? [...Tails[]] extends [] ? [] : [...Tails[]] extends [Head] ? [GetCreateQueryResult<...>, GetCreateQueryResult<...>] : [...(...)[]] extends [..., ...(...)[]] ? ... extends ... ? ... : ... : [...(...)[]] : { [K in string | number | symbol]: GetCreateQueryResult]> }) => TCombinedResult; + combine?: (result: T extends [] ? [] : T extends [Head] ? [GetCreateQueryResult] : T extends [Head, ...Tails[]] ? [...Tails[]] extends [] ? [] : [...Tails[]] extends [Head] ? [GetCreateQueryResult<...>, GetCreateQueryResult<...>] : [...(...)[]] extends [..., ...(...)[]] ? ... extends ... ? ... : ... : [...(...)[]] : { [K in string | number | symbol]: GetCreateQueryResult }) => TCombinedResult; queries: | readonly [T extends [] ? [] : T extends [Head] ? [GetCreateQueryOptionsForCreateQueries] : T extends [Head, ...Tails[]] ? [...Tails[]] extends [] ? [] : [...Tails[]] extends [Head] ? [GetCreateQueryOptionsForCreateQueries<...>, GetCreateQueryOptionsForCreateQueries<...>] : [...(...)[]] extends [..., ...(...)[]] ? ... extends ... ? ... : ... : ... extends ... ? ... : ... : readonly unknown[] extends T ? T : T extends CreateQueryOptionsForCreateQueries<..., ..., ..., ...>[] ? CreateQueryOptionsForCreateQueries<..., ..., ..., ...>[] : CreateQueryOptionsForCreateQueries<..., ..., ..., ...>[]] - | readonly [{ [K in string | number | symbol]: GetCreateQueryOptionsForCreateQueries]> }]; + | readonly [{ [K in string | number | symbol]: GetCreateQueryOptionsForCreateQueries }]; }>, queryClient?: Accessor): TCombinedResult; ``` @@ -23,16 +23,16 @@ The `createQueries` function can be used to fetch a variable number of queries. ### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>, `GetCreateQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>, `GetCreateQueryResult`\<`Head`\>, `GetCreateQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetCreateQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetCreateQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>, `GetCreateQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>, `GetCreateQueryResult`\<`Head`\>, `GetCreateQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetCreateQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetCreateQueryResult\ \} ## Parameters ### createQueriesOptions [`Accessor`](../type-aliases/Accessor.md)\<\{ - `combine?`: (`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<...\>, `GetCreateQueryResult`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \{ \[K in string \| number \| symbol\]: GetCreateQueryResult\\]\> \}) => `TCombinedResult`; + `combine?`: (`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryResult`\<...\>, `GetCreateQueryResult`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \{ \[K in string \| number \| symbol\]: GetCreateQueryResult\ \}) => `TCombinedResult`; `queries`: \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetCreateQueryOptionsForCreateQueries`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetCreateQueryOptionsForCreateQueries`\<...\>, `GetCreateQueryOptionsForCreateQueries`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : ... *extends* ... ? ... : ... : readonly `unknown`[] *extends* `T` ? `T` : `T` *extends* `CreateQueryOptionsForCreateQueries`\<..., ..., ..., ...\>[] ? `CreateQueryOptionsForCreateQueries`\<..., ..., ..., ...\>[] : `CreateQueryOptionsForCreateQueries`\<..., ..., ..., ...\>[]\] - \| readonly \[\{ \[K in string \| number \| symbol\]: GetCreateQueryOptionsForCreateQueries\\]\> \}\]; + \| readonly \[\{ \[K in string \| number \| symbol\]: GetCreateQueryOptionsForCreateQueries\ \}\]; \}\> The `queries` array to run, and an optional `combine` function, wrapped in an diff --git a/docs/framework/svelte/reference/functions/dehydrate.md b/docs/framework/svelte/reference/functions/dehydrate.md index 201200efdfa..4999cadaf08 100644 --- a/docs/framework/svelte/reference/functions/dehydrate.md +++ b/docs/framework/svelte/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/svelte/reference/functions/experimental_streamedQuery.md b/docs/framework/svelte/reference/functions/experimental_streamedQuery.md index 29a8ae5d889..791a80817f2 100644 --- a/docs/framework/svelte/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/svelte/reference/functions/experimental_streamedQuery.md @@ -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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/svelte/reference/functions/keepPreviousData.md b/docs/framework/svelte/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/svelte/reference/functions/keepPreviousData.md +++ b/docs/framework/svelte/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/svelte/reference/functions/shouldThrowError.md b/docs/framework/svelte/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/svelte/reference/functions/shouldThrowError.md +++ b/docs/framework/svelte/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/svelte/reference/functions/useMutationState.md b/docs/framework/svelte/reference/functions/useMutationState.md index 4eb83ce595a..050f752c8d3 100644 --- a/docs/framework/svelte/reference/functions/useMutationState.md +++ b/docs/framework/svelte/reference/functions/useMutationState.md @@ -4,7 +4,7 @@ title: useMutationState --- ```ts -function useMutationState(options: MutationStateOptions, queryClient?: QueryClient): TResult[]; +function useMutationState(options?: MutationStateOptions, queryClient?: QueryClient): TResult[]; ``` Defined in: [packages/svelte-query/src/useMutationState.svelte.ts:100](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/useMutationState.svelte.ts#L100) @@ -25,7 +25,7 @@ state. ## Parameters -### options +### options? [`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`, `TMutation`\> = `{}` diff --git a/docs/framework/svelte/reference/interfaces/CancelOptions.md b/docs/framework/svelte/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/svelte/reference/interfaces/CancelOptions.md +++ b/docs/framework/svelte/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/svelte/reference/interfaces/DefaultOptions.md b/docs/framework/svelte/reference/interfaces/DefaultOptions.md index 7fae14fb540..9a73763ed09 100644 --- a/docs/framework/svelte/reference/interfaces/DefaultOptions.md +++ b/docs/framework/svelte/reference/interfaces/DefaultOptions.md @@ -15,10 +15,10 @@ Defined in: [packages/query-core/src/types.ts:1621](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | diff --git a/docs/framework/svelte/reference/interfaces/DehydrateOptions.md b/docs/framework/svelte/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/svelte/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/svelte/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/svelte/reference/interfaces/DehydratedState.md b/docs/framework/svelte/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/svelte/reference/interfaces/DehydratedState.md +++ b/docs/framework/svelte/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md b/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md b/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md index 19c4260bf7b..90e0625d587 100644 --- a/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/svelte/reference/interfaces/FocusManager.md b/docs/framework/svelte/reference/interfaces/FocusManager.md index 71c585966d2..3d59e85c451 100644 --- a/docs/framework/svelte/reference/interfaces/FocusManager.md +++ b/docs/framework/svelte/reference/interfaces/FocusManager.md @@ -174,13 +174,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/svelte/reference/interfaces/HydrateOptions.md b/docs/framework/svelte/reference/interfaces/HydrateOptions.md index eccc9b8b513..30c57539b89 100644 --- a/docs/framework/svelte/reference/interfaces/HydrateOptions.md +++ b/docs/framework/svelte/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteData.md b/docs/framework/svelte/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteData.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md index d1642d98ff2..858435e5774 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md @@ -35,33 +35,33 @@ Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md index a07f20cadf8..a475eb9b048 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/svelte/reference/interfaces/InitialPageParam.md b/docs/framework/svelte/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/svelte/reference/interfaces/InitialPageParam.md +++ b/docs/framework/svelte/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/svelte/reference/interfaces/InvalidateOptions.md b/docs/framework/svelte/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/svelte/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/svelte/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/svelte/reference/interfaces/MutateOptions.md b/docs/framework/svelte/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/svelte/reference/interfaces/MutateOptions.md +++ b/docs/framework/svelte/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md b/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/svelte/reference/interfaces/MutationFilters.md b/docs/framework/svelte/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/svelte/reference/interfaces/MutationFilters.md +++ b/docs/framework/svelte/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md b/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md index 771cea89665..1920ce66911 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationOptions.md b/docs/framework/svelte/reference/interfaces/MutationOptions.md index 323929c077d..9170d982368 100644 --- a/docs/framework/svelte/reference/interfaces/MutationOptions.md +++ b/docs/framework/svelte/reference/interfaces/MutationOptions.md @@ -31,15 +31,15 @@ Defined in: [packages/query-core/src/types.ts:1271](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | diff --git a/docs/framework/svelte/reference/interfaces/MutationState.md b/docs/framework/svelte/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/svelte/reference/interfaces/MutationState.md +++ b/docs/framework/svelte/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/svelte/reference/interfaces/NotifyEvent.md b/docs/framework/svelte/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/svelte/reference/interfaces/NotifyEvent.md +++ b/docs/framework/svelte/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/svelte/reference/interfaces/OnlineManager.md b/docs/framework/svelte/reference/interfaces/OnlineManager.md index 1ed3eebcf25..7e97e7bc137 100644 --- a/docs/framework/svelte/reference/interfaces/OnlineManager.md +++ b/docs/framework/svelte/reference/interfaces/OnlineManager.md @@ -151,13 +151,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md b/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md b/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/svelte/reference/interfaces/QueryClientConfig.md b/docs/framework/svelte/reference/interfaces/QueryClientConfig.md index a314893a143..58fbbc0ffe7 100644 --- a/docs/framework/svelte/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/svelte/reference/interfaces/QueryClientConfig.md @@ -9,6 +9,6 @@ Defined in: [packages/query-core/src/types.ts:1609](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | -| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | -| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | +| `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | +| `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | diff --git a/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md b/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md index 4563e570678..49e37ad9f95 100644 --- a/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/svelte/reference/interfaces/QueryFilters.md b/docs/framework/svelte/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/svelte/reference/interfaces/QueryFilters.md +++ b/docs/framework/svelte/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md b/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md index 9149bc22de4..b432ed89a0c 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md @@ -43,30 +43,30 @@ Defined in: [packages/query-core/src/types.ts:432](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryOptions.md b/docs/framework/svelte/reference/interfaces/QueryOptions.md index 3e4dbb3024a..966d8824818 100644 --- a/docs/framework/svelte/reference/interfaces/QueryOptions.md +++ b/docs/framework/svelte/reference/interfaces/QueryOptions.md @@ -31,17 +31,17 @@ Defined in: [packages/query-core/src/types.ts:276](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) \| *typeof* [`skipToken`](../variables/skipToken.md) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey?` | `TQueryKey` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/svelte/reference/interfaces/QueryState.md b/docs/framework/svelte/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/svelte/reference/interfaces/QueryState.md +++ b/docs/framework/svelte/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/svelte/reference/interfaces/RefetchOptions.md b/docs/framework/svelte/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/svelte/reference/interfaces/RefetchOptions.md +++ b/docs/framework/svelte/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md b/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/svelte/reference/interfaces/ResetOptions.md b/docs/framework/svelte/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/svelte/reference/interfaces/ResetOptions.md +++ b/docs/framework/svelte/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/svelte/reference/interfaces/ResultOptions.md b/docs/framework/svelte/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/svelte/reference/interfaces/ResultOptions.md +++ b/docs/framework/svelte/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/svelte/reference/interfaces/SetDataOptions.md b/docs/framework/svelte/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/svelte/reference/interfaces/SetDataOptions.md +++ b/docs/framework/svelte/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/svelte/reference/interfaces/TimeoutManager.md b/docs/framework/svelte/reference/interfaces/TimeoutManager.md index 317213619d5..164487133a6 100644 --- a/docs/framework/svelte/reference/interfaces/TimeoutManager.md +++ b/docs/framework/svelte/reference/interfaces/TimeoutManager.md @@ -37,7 +37,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -58,7 +58,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -78,7 +80,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -99,7 +101,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -144,7 +148,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -192,7 +198,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/svelte/reference/type-aliases/AnyDataTag.md b/docs/framework/svelte/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/svelte/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/svelte/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index 4d6b305fb5e..dbdacb7e38f 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -16,7 +16,7 @@ Defined in: [packages/svelte-query/src/infiniteQueryOptions.ts:32](https://githu ```ts initialData: | NonUndefinedGuard> -| () => NonUndefinedGuard>; + | (() => NonUndefinedGuard>); ``` ## Type Parameters diff --git a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md index cae4be41500..630f9697999 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md @@ -16,7 +16,7 @@ Defined in: [packages/svelte-query/src/queryOptions.ts:22](https://github.com/Ta ```ts initialData: | NonUndefinedGuard -| () => NonUndefinedGuard; + | (() => NonUndefinedGuard); ``` ## Type Parameters diff --git a/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md b/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md index 5cb260a4371..6dbc2879129 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | [`QueryClient`](../classes/QueryClient.md) | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/svelte/reference/type-aliases/MutationScope.md b/docs/framework/svelte/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationScope.md +++ b/docs/framework/svelte/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md b/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md index 49c06151b4f..8cce7b1c07c 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md @@ -25,5 +25,5 @@ Options for useMutationState | Property | Type | | ------ | ------ | -| `filters?` | [`MutationFilters`](../interfaces/MutationFilters.md) | -| `select?` | (`mutation`: `TMutation`) => `TResult` | +| `filters?` | [`MutationFilters`](../interfaces/MutationFilters.md) | +| `select?` | (`mutation`: `TMutation`) => `TResult` | diff --git a/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md index 9191c25c7d9..9b658cb5e6b 100644 --- a/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md index d35d6161a39..fc88186764a 100644 --- a/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md b/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md index 45daab83127..5a63f8dae29 100644 --- a/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md index 987c6d34eb9..d4e3c1e9d1d 100644 --- a/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md @@ -13,5 +13,5 @@ Defined in: [packages/svelte-query/src/types.ts:167](https://github.com/TanStack | Property | Type | | ------ | ------ | -| `children` | `Snippet` | -| `client` | [`QueryClient`](../classes/QueryClient.md) | +| `children` | `Snippet` | +| `client` | [`QueryClient`](../classes/QueryClient.md) | diff --git a/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md b/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md index 761e1af5402..ba9b538fa66 100644 --- a/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/svelte/reference/type-aliases/ThrowOnError.md b/docs/framework/svelte/reference/type-aliases/ThrowOnError.md index ffed6038ff5..40b1fcd4739 100644 --- a/docs/framework/svelte/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/svelte/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md b/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index a0d8c1907d6..ab623d0ae9c 100644 --- a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/svelte-query/src/infiniteQueryOptions.ts:11](https://githu ### initialData? ```ts -optional initialData: +optional initialData?: | NonUndefinedGuard> | InitialDataFunction>>; ``` diff --git a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md index b0ddb6cb6a5..9a3624daa30 100644 --- a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/svelte-query/src/queryOptions.ts:10](https://github.com/Ta ### initialData? ```ts -optional initialData: +optional initialData?: | InitialDataFunction> | NonUndefinedGuard; ``` diff --git a/docs/framework/svelte/reference/type-aliases/Updater.md b/docs/framework/svelte/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/svelte/reference/type-aliases/Updater.md +++ b/docs/framework/svelte/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/svelte/reference/variables/environmentManager.md b/docs/framework/svelte/reference/variables/environmentManager.md index 4f88d27d2a9..1b5f65b6a99 100644 --- a/docs/framework/svelte/reference/variables/environmentManager.md +++ b/docs/framework/svelte/reference/variables/environmentManager.md @@ -20,7 +20,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/svelte/reference/variables/notifyManager.md b/docs/framework/svelte/reference/variables/notifyManager.md index c2c071b42a5..abc590e3442 100644 --- a/docs/framework/svelte/reference/variables/notifyManager.md +++ b/docs/framework/svelte/reference/variables/notifyManager.md @@ -13,7 +13,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -40,7 +40,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -64,7 +64,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -83,7 +83,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -112,7 +112,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -131,7 +131,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; diff --git a/docs/framework/vue/reference/classes/CancelledError.md b/docs/framework/vue/reference/classes/CancelledError.md index 5bd8c049574..296c3e59d58 100644 --- a/docs/framework/vue/reference/classes/CancelledError.md +++ b/docs/framework/vue/reference/classes/CancelledError.md @@ -59,7 +59,7 @@ Error.constructor ### cause? ```ts -optional cause: unknown; +optional cause?: unknown; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 @@ -107,7 +107,7 @@ Error.name ### revert? ```ts -optional revert: boolean; +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) @@ -117,7 +117,7 @@ Defined in: [packages/query-core/src/retryer.ts:82](https://github.com/TanStack/ ### silent? ```ts -optional silent: boolean; +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) @@ -127,7 +127,7 @@ Defined in: [packages/query-core/src/retryer.ts:83](https://github.com/TanStack/ ### stack? ```ts -optional stack: string; +optional stack?: string; ``` Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 diff --git a/docs/framework/vue/reference/classes/InfiniteQueryObserver.md b/docs/framework/vue/reference/classes/InfiniteQueryObserver.md index f76589a9939..cd891813557 100644 --- a/docs/framework/vue/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/vue/reference/classes/InfiniteQueryObserver.md @@ -122,7 +122,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan *** -### subscribe() +### subscribe ```ts subscribe: (listener: InfiniteQueryObserverListener) => () => void; @@ -144,13 +144,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -384,7 +378,7 @@ Returns `true` while at least one listener is registered, `false` once they have ### 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) @@ -394,7 +388,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -530,7 +524,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/vue/reference/classes/MutationCache.md b/docs/framework/vue/reference/classes/MutationCache.md index e0fee7525f7..9465fefe61f 100644 --- a/docs/framework/vue/reference/classes/MutationCache.md +++ b/docs/framework/vue/reference/classes/MutationCache.md @@ -18,14 +18,14 @@ MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping ### 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) #### Parameters -##### config +##### config? [`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` @@ -155,7 +155,7 @@ MC.find ### findAll() ```ts -findAll(filters: MaybeRefDeep>): Mutation[]; +findAll(filters?: MaybeRefDeep>): Mutation[]; ``` Defined in: [packages/vue-query/src/mutationCache.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L27) @@ -168,7 +168,7 @@ information about mutations in rare scenarios. #### Parameters -##### filters +##### filters? `MaybeRefDeep`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` @@ -273,13 +273,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/vue/reference/classes/MutationObserver.md b/docs/framework/vue/reference/classes/MutationObserver.md index f6ab38a37df..cdb0fbe8ac1 100644 --- a/docs/framework/vue/reference/classes/MutationObserver.md +++ b/docs/framework/vue/reference/classes/MutationObserver.md @@ -258,13 +258,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/vue/reference/classes/QueriesObserver.md b/docs/framework/vue/reference/classes/QueriesObserver.md index 5384ac3e249..82eae3afdfa 100644 --- a/docs/framework/vue/reference/classes/QueriesObserver.md +++ b/docs/framework/vue/reference/classes/QueriesObserver.md @@ -155,7 +155,7 @@ wrap the results for property-access tracking. ##### combine -`CombineFn`\<`TCombinedResult`\> | `undefined` +`CombineFn`\<`TCombinedResult`\> \| `undefined` #### Returns @@ -262,13 +262,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/vue/reference/classes/Query.md b/docs/framework/vue/reference/classes/Query.md index 7cba080a4b4..30b20ec99a2 100644 --- a/docs/framework/vue/reference/classes/Query.md +++ b/docs/framework/vue/reference/classes/Query.md @@ -407,7 +407,7 @@ if (query.isStale()) { ### isStaleByTime() ```ts -isStaleByTime(staleTime: number | "static"): boolean; +isStaleByTime(staleTime?: number | "static"): boolean; ``` Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) @@ -421,9 +421,9 @@ Returns `true` if the query's data is stale relative to the given #### Parameters -##### staleTime +##### staleTime? -`number` | `"static"` +`number` \| `"static"` #### Returns diff --git a/docs/framework/vue/reference/classes/QueryCache.md b/docs/framework/vue/reference/classes/QueryCache.md index d0eb9f6c3cc..57cea9626f9 100644 --- a/docs/framework/vue/reference/classes/QueryCache.md +++ b/docs/framework/vue/reference/classes/QueryCache.md @@ -18,14 +18,14 @@ MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping ### 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) #### Parameters -##### config +##### config? [`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` @@ -225,7 +225,7 @@ QC.find ### findAll() ```ts -findAll(filters: MaybeRefDeep>): Query[]; +findAll(filters?: MaybeRefDeep>): Query[]; ``` Defined in: [packages/vue-query/src/queryCache.ts:23](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L23) @@ -238,7 +238,7 @@ information about queries in rare scenarios. #### Parameters -##### filters +##### filters? `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` @@ -443,13 +443,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/vue/reference/classes/QueryClient.md b/docs/framework/vue/reference/classes/QueryClient.md index 0c7b7bbc845..be2d36f1aa5 100644 --- a/docs/framework/vue/reference/classes/QueryClient.md +++ b/docs/framework/vue/reference/classes/QueryClient.md @@ -27,14 +27,14 @@ Install one on your app with `VueQueryPlugin`, or retrieve it with `useQueryClie ### Constructor ```ts -new QueryClient(config: QueryClientConfig): QueryClient; +new QueryClient(config?: QueryClientConfig): QueryClient; ``` Defined in: [packages/vue-query/src/queryClient.ts:52](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L52) #### Parameters -##### config +##### config? `QueryClientConfig` = `{}` @@ -53,7 +53,7 @@ QC.constructor ### isRestoring? ```ts -optional isRestoring: Ref; +optional isRestoring?: Ref; ``` Defined in: [packages/vue-query/src/queryClient.ts:65](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L65) @@ -225,7 +225,8 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). ##### options -[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> #### Returns @@ -548,7 +549,7 @@ QC.fetchQuery ```ts fetchQuery(options: | MaybeRefDeep> -| () => FetchQueryOptions): Promise; +| (() => FetchQueryOptions)): Promise; ``` Defined in: [packages/vue-query/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L336) @@ -579,7 +580,8 @@ Defined in: [packages/vue-query/src/queryClient.ts:336](https://github.com/TanSt ###### options -`MaybeRefDeep`\<[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> | () => [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + \| `MaybeRefDeep`\<[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> + \| (() => [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>) ##### Returns @@ -1073,7 +1075,7 @@ QC.infiniteQuery ```ts invalidateQueries(filters?: | InvalidateQueryFilters -| () => InvalidateQueryFilters, options?: MaybeRefDeep): Promise; +| (() => InvalidateQueryFilters), options?: MaybeRefDeep): Promise; ``` Defined in: [packages/vue-query/src/queryClient.ts:204](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L204) @@ -1095,7 +1097,8 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi ##### filters? -[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> | () => [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + \| [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + \| (() => [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\>) ##### options? @@ -1122,7 +1125,7 @@ QC.invalidateQueries ### isFetching() ```ts -isFetching(filters: MaybeRefDeep>): number; +isFetching(filters?: MaybeRefDeep>): number; ``` Defined in: [packages/vue-query/src/queryClient.ts:67](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L67) @@ -1133,7 +1136,7 @@ loading more infinite query results. #### Parameters -##### filters +##### filters? `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` @@ -1160,7 +1163,7 @@ QC.isFetching ### isMutating() ```ts -isMutating(filters: MaybeRefDeep>): number; +isMutating(filters?: MaybeRefDeep>): number; ``` Defined in: [packages/vue-query/src/queryClient.ts:71](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L71) @@ -1170,7 +1173,7 @@ matching a set of filters. #### Parameters -##### filters +##### filters? `MaybeRefDeep`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` @@ -1840,7 +1843,7 @@ QC.setMutationDefaults setQueriesData( filters: MaybeRefDeep>, updater: Updater, - options: MaybeRefDeep): [readonly unknown[], TData | undefined][]; + options?: MaybeRefDeep): [readonly unknown[], TData | undefined][]; ``` Defined in: [packages/vue-query/src/queryClient.ts:157](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L157) @@ -1866,7 +1869,7 @@ filters are updated; no new cache entries are created. Internally this calls [`Updater`](../type-aliases/Updater.md)\<`TData` \| `undefined`, `TData` \| `undefined`\> -##### options +##### options? `MaybeRefDeep`\<[`SetDataOptions`](../interfaces/SetDataOptions.md)\> = `{}` diff --git a/docs/framework/vue/reference/classes/QueryObserver.md b/docs/framework/vue/reference/classes/QueryObserver.md index 7c235cb5005..0ac42909a4b 100644 --- a/docs/framework/vue/reference/classes/QueryObserver.md +++ b/docs/framework/vue/reference/classes/QueryObserver.md @@ -243,7 +243,7 @@ Subscribable.hasListeners ### 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) @@ -253,7 +253,7 @@ the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters +##### \_\_namedParameters? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` @@ -362,13 +362,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example @@ -430,7 +424,31 @@ 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"` + \| `"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"` #### Returns diff --git a/docs/framework/vue/reference/functions/dehydrate.md b/docs/framework/vue/reference/functions/dehydrate.md index 782758a4380..78d9ea88531 100644 --- a/docs/framework/vue/reference/functions/dehydrate.md +++ b/docs/framework/vue/reference/functions/dehydrate.md @@ -4,7 +4,7 @@ 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) @@ -21,7 +21,7 @@ falling back to the client's `dehydrate` default options, and finally to `defaul `QueryClient` -### options +### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` diff --git a/docs/framework/vue/reference/functions/experimental_streamedQuery.md b/docs/framework/vue/reference/functions/experimental_streamedQuery.md index 0318cf7c16a..791a80817f2 100644 --- a/docs/framework/vue/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/vue/reference/functions/experimental_streamedQuery.md @@ -38,45 +38,7 @@ The function that returns an AsyncIterable to stream data from. ## Returns -```ts -(context: object): TData | Promise; -``` - -### Parameters - -#### context - -##### client - -`QueryClient` - -##### 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`\> +(`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/vue/reference/functions/keepPreviousData.md b/docs/framework/vue/reference/functions/keepPreviousData.md index 930de5e2078..5f2d328a5b8 100644 --- a/docs/framework/vue/reference/functions/keepPreviousData.md +++ b/docs/framework/vue/reference/functions/keepPreviousData.md @@ -23,7 +23,7 @@ query key is fetching, it keeps displaying the previously fetched data until the ### previousData -`T` | `undefined` +`T` \| `undefined` ## Returns diff --git a/docs/framework/vue/reference/functions/mutationOptions.md b/docs/framework/vue/reference/functions/mutationOptions.md index 7d1081744cd..c4902687439 100644 --- a/docs/framework/vue/reference/functions/mutationOptions.md +++ b/docs/framework/vue/reference/functions/mutationOptions.md @@ -122,13 +122,7 @@ re-evaluated on demand. A function that returns the same options object, unchanged. -```ts -(): WithRequired, "mutationKey">; -``` - -#### Returns - -[`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +() => [`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> ### See @@ -271,13 +265,7 @@ demand. A function that returns the same options object, unchanged. -```ts -(): Omit, "mutationKey">; -``` - -#### Returns - -`Omit`\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +() => `Omit`\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> ### See diff --git a/docs/framework/vue/reference/functions/queryOptions.md b/docs/framework/vue/reference/functions/queryOptions.md index af4ddcd4b01..a6ff6c14be4 100644 --- a/docs/framework/vue/reference/functions/queryOptions.md +++ b/docs/framework/vue/reference/functions/queryOptions.md @@ -118,13 +118,7 @@ A function returning the [DefinedInitialQueryOptions](../type-aliases/DefinedIni A function that returns the same options object, typed so that `queryKey` carries the inferred data type. -```ts -(): DefinedInitialQueryOptionsWithDataTag; -``` - -#### Returns - -[`DefinedInitialQueryOptionsWithDataTag`](../type-aliases/DefinedInitialQueryOptionsWithDataTag.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +() => [`DefinedInitialQueryOptionsWithDataTag`](../type-aliases/DefinedInitialQueryOptionsWithDataTag.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> ### See @@ -260,13 +254,7 @@ demand. A function that returns the same options object, typed so that `queryKey` carries the inferred data type. -```ts -(): UndefinedInitialQueryOptionsWithDataTag; -``` - -#### Returns - -[`UndefinedInitialQueryOptionsWithDataTag`](../type-aliases/UndefinedInitialQueryOptionsWithDataTag.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +() => [`UndefinedInitialQueryOptionsWithDataTag`](../type-aliases/UndefinedInitialQueryOptionsWithDataTag.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> ### See diff --git a/docs/framework/vue/reference/functions/shouldThrowError.md b/docs/framework/vue/reference/functions/shouldThrowError.md index 3ebed7be214..7d26951a636 100644 --- a/docs/framework/vue/reference/functions/shouldThrowError.md +++ b/docs/framework/vue/reference/functions/shouldThrowError.md @@ -25,7 +25,7 @@ resolves to `false`). ### throwOnError -`boolean` | `T` | `undefined` +`boolean` \| `T` \| `undefined` ### params diff --git a/docs/framework/vue/reference/functions/useIsFetching.md b/docs/framework/vue/reference/functions/useIsFetching.md index fcf941372be..37f98447d30 100644 --- a/docs/framework/vue/reference/functions/useIsFetching.md +++ b/docs/framework/vue/reference/functions/useIsFetching.md @@ -6,7 +6,7 @@ redirect_from: --- ```ts -function useIsFetching(fetchingFilters: UseIsFetchingFilters, queryClient?: QueryClient): Ref; +function useIsFetching(fetchingFilters?: UseIsFetchingFilters, queryClient?: QueryClient): Ref; ``` Defined in: [packages/vue-query/src/useIsFetching.ts:53](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L53) @@ -19,7 +19,7 @@ getter if the filters themselves depend on other reactive state. ## Parameters -### fetchingFilters +### fetchingFilters? [`UseIsFetchingFilters`](../type-aliases/UseIsFetchingFilters.md) = `{}` diff --git a/docs/framework/vue/reference/functions/useIsMutating.md b/docs/framework/vue/reference/functions/useIsMutating.md index b237105214d..77db55d0425 100644 --- a/docs/framework/vue/reference/functions/useIsMutating.md +++ b/docs/framework/vue/reference/functions/useIsMutating.md @@ -6,7 +6,7 @@ redirect_from: --- ```ts -function useIsMutating(filters: UseIsMutatingFilters, queryClient?: QueryClient): Ref; +function useIsMutating(filters?: UseIsMutatingFilters, queryClient?: QueryClient): Ref; ``` Defined in: [packages/vue-query/src/useMutationState.ts:52](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L52) @@ -19,7 +19,7 @@ the filters themselves depend on other reactive state. ## Parameters -### filters +### filters? [`UseIsMutatingFilters`](../type-aliases/UseIsMutatingFilters.md) = `{}` diff --git a/docs/framework/vue/reference/functions/useMutationState.md b/docs/framework/vue/reference/functions/useMutationState.md index ac60f36d1f1..22c3666bb66 100644 --- a/docs/framework/vue/reference/functions/useMutationState.md +++ b/docs/framework/vue/reference/functions/useMutationState.md @@ -6,9 +6,9 @@ redirect_from: --- ```ts -function useMutationState(options: +function useMutationState(options?: | MutationStateOptions -| () => MutationStateOptions, queryClient?: QueryClient): Readonly>; +| (() => MutationStateOptions), queryClient?: QueryClient): Readonly>; ``` Defined in: [packages/vue-query/src/useMutationState.ts:195](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L195) @@ -32,13 +32,14 @@ themselves depend on other reactive state. ## Parameters -### options +### options? + + \| [`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`, `TMutation`\> + \| (() => [`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`, `TMutation`\>) The `filters` to narrow down matched mutations, and an optional `select` to transform the mutation state. -[`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`, `TMutation`\> | () => [`MutationStateOptions`](../type-aliases/MutationStateOptions.md)\<`TResult`, `TMutation`\> - ### queryClient? [`QueryClient`](../classes/QueryClient.md) diff --git a/docs/framework/vue/reference/functions/useQueries.md b/docs/framework/vue/reference/functions/useQueries.md index 13e3f705411..1f1fdb270a3 100644 --- a/docs/framework/vue/reference/functions/useQueries.md +++ b/docs/framework/vue/reference/functions/useQueries.md @@ -35,7 +35,7 @@ previously rendered queries, because the number of queries can differ between re ### TCombinedResult -`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\\]\> \} +`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>, `GetUseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseQueryResult\ \} ## Parameters diff --git a/docs/framework/vue/reference/functions/useQueryClient.md b/docs/framework/vue/reference/functions/useQueryClient.md index 2244338bef7..958ebf20eaf 100644 --- a/docs/framework/vue/reference/functions/useQueryClient.md +++ b/docs/framework/vue/reference/functions/useQueryClient.md @@ -6,7 +6,7 @@ redirect_from: --- ```ts -function useQueryClient(id: string): QueryClient; +function useQueryClient(id?: string): QueryClient; ``` Defined in: [packages/vue-query/src/useQueryClient.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueryClient.ts#L27) @@ -16,7 +16,7 @@ Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. M ## Parameters -### id +### id? `string` = `''` diff --git a/docs/framework/vue/reference/interfaces/CancelOptions.md b/docs/framework/vue/reference/interfaces/CancelOptions.md index b9b04adb6c2..030a2f61208 100644 --- a/docs/framework/vue/reference/interfaces/CancelOptions.md +++ b/docs/framework/vue/reference/interfaces/CancelOptions.md @@ -12,5 +12,5 @@ They are carried on the [CancelledError](../classes/CancelledError.md) that the | Property | Type | | ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| `revert?` | `boolean` | +| `silent?` | `boolean` | diff --git a/docs/framework/vue/reference/interfaces/DefaultOptions.md b/docs/framework/vue/reference/interfaces/DefaultOptions.md index e980b6aa6ef..d4ab48ee488 100644 --- a/docs/framework/vue/reference/interfaces/DefaultOptions.md +++ b/docs/framework/vue/reference/interfaces/DefaultOptions.md @@ -15,10 +15,10 @@ Defined in: [packages/query-core/src/types.ts:1621](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | `MutationOptions`\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | `QueryOptions`\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | -| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | +| `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"` \| `"suspense"`, `"strictly"`\> | Default options applied to every query, unless overridden per-query. | diff --git a/docs/framework/vue/reference/interfaces/DehydrateOptions.md b/docs/framework/vue/reference/interfaces/DehydrateOptions.md index 23717093d3c..d2dfae426d5 100644 --- a/docs/framework/vue/reference/interfaces/DehydrateOptions.md +++ b/docs/framework/vue/reference/interfaces/DehydrateOptions.md @@ -12,7 +12,7 @@ how their data/errors are transformed before being serialized (e.g. for embeddin | Property | Type | Description | | ------ | ------ | ------ | -| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | -| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | -| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | -| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | +| `serializeData?` | `TransformerFn` | Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. | +| `shouldDehydrateMutation?` | (`mutation`: [`Mutation`](../classes/Mutation.md)) => `boolean` | Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. | +| `shouldDehydrateQuery?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. | +| `shouldRedactErrors?` | (`error`: `unknown`) => `boolean` | Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the given error, in which case the original error is kept. | diff --git a/docs/framework/vue/reference/interfaces/DehydratedState.md b/docs/framework/vue/reference/interfaces/DehydratedState.md index 8668325a628..a5bd03abc5c 100644 --- a/docs/framework/vue/reference/interfaces/DehydratedState.md +++ b/docs/framework/vue/reference/interfaces/DehydratedState.md @@ -13,5 +13,5 @@ that has already been fetched, avoiding a redundant fetch on the client. | Property | Type | | ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| `mutations` | `DehydratedMutation`[] | +| `queries` | `DehydratedQuery`[] | diff --git a/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md index 0ca9f0db032..8d397ddfdd3 100644 --- a/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md @@ -37,20 +37,20 @@ Defined in: [packages/query-core/src/types.ts:670](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md b/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md index bd3568af5d5..fe3b1e09ee9 100644 --- a/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md +++ b/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:794](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md index a0bfec1ed8f..0afa3b8197c 100644 --- a/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md +++ b/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:806](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/vue/reference/interfaces/FetchQueryOptions.md b/docs/framework/vue/reference/interfaces/FetchQueryOptions.md index acafe171c1d..39161409b85 100644 --- a/docs/framework/vue/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/vue/reference/interfaces/FetchQueryOptions.md @@ -41,19 +41,19 @@ Defined in: [packages/query-core/src/types.ts:651](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| ~~`initialData?`~~ | `TData` \| () => `TData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| ~~`initialDataUpdatedAt?`~~ | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | -| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| ~~`retryDelay?`~~ | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`staleTime?`~~ | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| ~~`structuralSharing?`~~ | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| ~~`persister?`~~ | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| ~~`queryFn?`~~ | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| ~~`queryHash?`~~ | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| ~~`queryKey`~~ | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/vue/reference/interfaces/FocusManager.md b/docs/framework/vue/reference/interfaces/FocusManager.md index 71c585966d2..3d59e85c451 100644 --- a/docs/framework/vue/reference/interfaces/FocusManager.md +++ b/docs/framework/vue/reference/interfaces/FocusManager.md @@ -174,13 +174,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/vue/reference/interfaces/HydrateOptions.md b/docs/framework/vue/reference/interfaces/HydrateOptions.md index 5d60315e073..3a628fc67e4 100644 --- a/docs/framework/vue/reference/interfaces/HydrateOptions.md +++ b/docs/framework/vue/reference/interfaces/HydrateOptions.md @@ -12,7 +12,7 @@ Options for `hydrate`, controlling the default options applied to queries/mutati | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | +| `defaultOptions?` | `object` | Options applied to the queries and mutations restored from the dehydrated state. | | `defaultOptions.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `defaultOptions.mutations?` | `MutationOptions`\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `defaultOptions.queries?` | `QueryOptions`\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/vue/reference/interfaces/InfiniteData.md b/docs/framework/vue/reference/interfaces/InfiniteData.md index a1249bdaa00..644aba1778c 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteData.md +++ b/docs/framework/vue/reference/interfaces/InfiniteData.md @@ -22,5 +22,5 @@ The data shape of an infinite query: every page fetched so far, plus the page pa | Property | Type | | ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| `pageParams` | `TPageParam`[] | +| `pages` | `TData`[] | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md index ff50f7aeb52..9a89f7d1c68 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -32,36 +32,36 @@ Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index 3d19f1628a7..6c819980c8c 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 779b38b6111..0b324598efa 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md index d1642d98ff2..858435e5774 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md @@ -35,33 +35,33 @@ Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| () => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| (() => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam` | `TPageParam` | `undefined` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| ((`previousData`: \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<[`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> \| `undefined`) => \| [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: [`InfiniteData`](InfiniteData.md)) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md index 9c6e954d81b..a104b0d92f2 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1099](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 848a0dff58a..e586b1948d2 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1186](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 6219efbdfca..9f28a431e73 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1152](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | -| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | +| `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 56075e72659..fe99ea04d54 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -23,36 +23,36 @@ Defined in: [packages/query-core/src/types.ts:1168](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | -| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | -| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | -| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchNextPage` | (`options?`: [`FetchNextPageOptions`](FetchNextPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the next "page" of results. | - | +| `fetchPreviousPage` | (`options?`: [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md)) => `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> | This function allows you to fetch the previous "page" of results. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | +| `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | +| `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | +| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md index a07f20cadf8..a475eb9b048 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | -| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. | +| `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/vue/reference/interfaces/InitialPageParam.md b/docs/framework/vue/reference/interfaces/InitialPageParam.md index 1a4a7b3a552..92619333367 100644 --- a/docs/framework/vue/reference/interfaces/InitialPageParam.md +++ b/docs/framework/vue/reference/interfaces/InitialPageParam.md @@ -19,4 +19,4 @@ Defined in: [packages/query-core/src/types.ts:392](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | +| `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. | diff --git a/docs/framework/vue/reference/interfaces/InvalidateOptions.md b/docs/framework/vue/reference/interfaces/InvalidateOptions.md index ac70493b13d..847b65f3c30 100644 --- a/docs/framework/vue/reference/interfaces/InvalidateOptions.md +++ b/docs/framework/vue/reference/interfaces/InvalidateOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:791](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md index 0405f856ad9..05701ae7b68 100644 --- a/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md +++ b/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md @@ -22,10 +22,10 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `refetchType?` | `QueryTypeFilter` \| `"none"` | `'active'` | Controls which of the matched (now-invalidated) queries are refetched in the background. - `'active'`: only queries with at least one active observer are refetched. - `'inactive'`: only queries with no active observer are refetched. - `'all'`: every matched query is refetched, active or not. - `'none'`: no query is refetched; matched queries are only marked as invalidated. | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/vue/reference/interfaces/MutateOptions.md b/docs/framework/vue/reference/interfaces/MutateOptions.md index 0b852015ba5..39047197c0b 100644 --- a/docs/framework/vue/reference/interfaces/MutateOptions.md +++ b/docs/framework/vue/reference/interfaces/MutateOptions.md @@ -27,6 +27,6 @@ Defined in: [packages/query-core/src/types.ts:1398](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | diff --git a/docs/framework/vue/reference/interfaces/MutationCacheConfig.md b/docs/framework/vue/reference/interfaces/MutationCacheConfig.md index 5bf99e108f5..cb6d312b044 100644 --- a/docs/framework/vue/reference/interfaces/MutationCacheConfig.md +++ b/docs/framework/vue/reference/interfaces/MutationCacheConfig.md @@ -16,7 +16,7 @@ If a callback returns a promise, it will be awaited before the mutation continue | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | -| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | +| `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. | +| `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. | diff --git a/docs/framework/vue/reference/interfaces/MutationFilters.md b/docs/framework/vue/reference/interfaces/MutationFilters.md index 5e760a7a543..887c1a2e84a 100644 --- a/docs/framework/vue/reference/interfaces/MutationFilters.md +++ b/docs/framework/vue/reference/interfaces/MutationFilters.md @@ -30,7 +30,7 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Description | | ------ | ------ | ------ | -| `exact?` | `boolean` | Match mutation key exactly | -| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | -| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | -| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | +| `exact?` | `boolean` | Match mutation key exactly | +| `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key | +| `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function | +| `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md index d746fb84394..a1d2a2d86cb 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md @@ -41,18 +41,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#data) | -| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | -| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | -| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | [`MutationState`](MutationState.md).[`data`](MutationState.md#property-data) | +| `error` | `TError` \| `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationState`](MutationState.md).[`error`](MutationState.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | - | +| `isIdle` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | - | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `boolean` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | - | +| `isSuccess` | `boolean` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | - | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationState`](MutationState.md).[`status`](MutationState.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` \| `undefined` | The variables object passed to the `mutationFn`. | [`MutationState`](MutationState.md).[`variables`](MutationState.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md index 920b293d6ea..5c19173b64e 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md index 27cdd03ab86..eb66df426c0 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md index 69d1c96d0f6..c9228d9e4ec 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverOptions.md b/docs/framework/vue/reference/interfaces/MutationObserverOptions.md index fb80b0f7eca..04926f83af4 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverOptions.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverOptions.md @@ -31,16 +31,16 @@ Defined in: [packages/query-core/src/types.ts:1381](https://github.com/TanStack/ | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | -| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | -| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | -| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | -| `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the `mutation` is available, such as the `onError` and `onSuccess` callbacks of the `MutationCache`. | +| `mutationFn?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `Promise`\<`TData`\> | `undefined` | The function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching `mutationKey` via `queryClient.setMutationDefaults`. Receives the `variables` passed to `mutate`, and a [MutationFunctionContext](../type-aliases/MutationFunctionContext.md) holding the `QueryClient`, the `mutationKey` and `meta`. Must return a promise that resolves the mutation's data. | +| `mutationKey?` | readonly `unknown`[] | `undefined` | The key to use for this mutation. Optional, but required to inherit defaults registered with `queryClient.setMutationDefaults`, and to match this mutation with `useMutationState` or `queryClient.isMutating`. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a mutation is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before `onSettled` runs. | +| `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | `undefined` | This function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to `onSuccess`, `onError` and `onSettled` as `onMutateResult`, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | `undefined` | This function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before `onSettled` runs. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `0` | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | `undefined` | Controls whether this mutation runs alongside others or waits its turn. Mutations sharing the same `scope.id` run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered. | +| `throwOnError?` | `boolean` \| ((`error`: `TError`) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md index 7bbe17af1b7..9e8934355ef 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md @@ -34,18 +34,18 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) | -| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** The variables object to pass to the `mutationFn`. **Param** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** This function will fire if the mutation encounters an error and will be passed the error. **Param** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | -| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | +| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | +| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | +| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | +| `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | +| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | +| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationState.md b/docs/framework/vue/reference/interfaces/MutationState.md index 62ce6ac5cde..2a46c9945a6 100644 --- a/docs/framework/vue/reference/interfaces/MutationState.md +++ b/docs/framework/vue/reference/interfaces/MutationState.md @@ -34,12 +34,12 @@ that observer results (e.g. `MutationObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | -| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | -| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | -| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | -| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | -| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | -| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | -| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | +| `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the mutation. | +| `error` | `TError` \| `null` | The error object for the mutation, if the last attempt resulted in an error. - Defaults to `null`. | +| `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | +| `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | +| `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | +| `status` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | The status of the mutation. | +| `submittedAt` | `number` | The timestamp for when the mutation was submitted. | +| `variables` | `TVariables` \| `undefined` | The variables the mutation was last called with. | diff --git a/docs/framework/vue/reference/interfaces/NotifyEvent.md b/docs/framework/vue/reference/interfaces/NotifyEvent.md index 3721113c91c..a6312b755b8 100644 --- a/docs/framework/vue/reference/interfaces/NotifyEvent.md +++ b/docs/framework/vue/reference/interfaces/NotifyEvent.md @@ -9,4 +9,4 @@ Defined in: [packages/query-core/src/types.ts:1663](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | diff --git a/docs/framework/vue/reference/interfaces/OnlineManager.md b/docs/framework/vue/reference/interfaces/OnlineManager.md index 1ed3eebcf25..7e97e7bc137 100644 --- a/docs/framework/vue/reference/interfaces/OnlineManager.md +++ b/docs/framework/vue/reference/interfaces/OnlineManager.md @@ -151,13 +151,7 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns -```ts -(): void; -``` - -##### Returns - -`void` +() => `void` #### Example diff --git a/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md b/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md index 012d9eb948b..a0a3e012f58 100644 --- a/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md +++ b/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/T | Property | Type | Description | | ------ | ------ | ------ | -| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | +| `combine?` | `CombineFn`\<`TCombinedResult`\> | A function that combines the array of `QueryObserverResult`s (one per observed query) into a single value. The combined value is memoized and only recomputed when one of the underlying results, the query hashes, or the `combine` function itself changes. Defaults to returning the array of `QueryObserverResult`s unchanged. | diff --git a/docs/framework/vue/reference/interfaces/QueryCacheConfig.md b/docs/framework/vue/reference/interfaces/QueryCacheConfig.md index b0742235c17..578f0cba3fa 100644 --- a/docs/framework/vue/reference/interfaces/QueryCacheConfig.md +++ b/docs/framework/vue/reference/interfaces/QueryCacheConfig.md @@ -14,6 +14,6 @@ are fire-and-forget: their return value is not awaited before the query settles. | Property | Type | Description | | ------ | ------ | ------ | -| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | -| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | -| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | +| `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. | +| `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. | +| `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. | diff --git a/docs/framework/vue/reference/interfaces/QueryClientConfig.md b/docs/framework/vue/reference/interfaces/QueryClientConfig.md index 93be5ca14b5..39fbb6558cf 100644 --- a/docs/framework/vue/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/vue/reference/interfaces/QueryClientConfig.md @@ -9,6 +9,6 @@ Defined in: [packages/query-core/src/types.ts:1609](https://github.com/TanStack/ | Property | Type | Description | | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | -| `mutationCache?` | `MutationCache` | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | -| `queryCache?` | `QueryCache` | The query cache this client is connected to. A new `QueryCache` is created if not provided. | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | +| `mutationCache?` | `MutationCache` | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | +| `queryCache?` | `QueryCache` | The query cache this client is connected to. A new `QueryCache` is created if not provided. | diff --git a/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md b/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md index 37ce506b6e5..18b5f4c4102 100644 --- a/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md @@ -39,20 +39,20 @@ Defined in: [packages/query-core/src/types.ts:626](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `initialPageParam?` | `undefined` | `undefined` | - | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the value this call resolves with, but does not affect what gets stored in the query cache. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/vue/reference/interfaces/QueryFilters.md b/docs/framework/vue/reference/interfaces/QueryFilters.md index 7d866400365..8002de1f481 100644 --- a/docs/framework/vue/reference/interfaces/QueryFilters.md +++ b/docs/framework/vue/reference/interfaces/QueryFilters.md @@ -23,9 +23,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md index 2f02c3bdf42..4263e264aac 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md @@ -29,28 +29,28 @@ Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/q | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | -| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | -| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | -| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | -| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | -| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | -| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | +| `isError` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | +| `isLoadingError` | `boolean` | Will be `true` if the query failed while fetching for the first time. | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | +| `isPending` | `boolean` | Will be `pending` if there's no cached data and no query attempt was finished yet. | +| `isPlaceholderData` | `boolean` | Will be `true` if the data shown is the placeholder data. | +| `isRefetchError` | `boolean` | Will be `true` if the query failed while refetching. | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | +| `isSuccess` | `boolean` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md index a9cca069649..6bd9455a4ed 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md index 99d5bf732ee..204fc0b8abe 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverOptions.md b/docs/framework/vue/reference/interfaces/QueryObserverOptions.md index 4ae5db2332c..06e87c1f532 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverOptions.md @@ -43,30 +43,30 @@ Defined in: [packages/query-core/src/types.ts:432](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `enabled?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | -| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | -| `initialData?` | `TQueryData` \| () => `TQueryData` \| `undefined` | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | -| `initialDataUpdatedAt?` | `number` \| () => `number` \| `undefined` | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | -| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | -| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | -| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| () => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined` | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | -| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | -| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| (`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined` | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | -| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | -| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | -| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | -| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | -| `refetchInterval?` | \| `number` \| `false` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined` | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | -| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | -| `refetchOnMount?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | -| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | -| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"` | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | -| `retry?` | \| `number` \| `false` \| `true` \| (`failureCount`: `number`, `error`: `TError`) => `boolean` | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | -| `retryDelay?` | `number` \| (`failureCount`: `number`, `error`: `TError`) => `number` | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| `retryOnMount?` | \| `false` \| `true` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | -| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | -| `staleTime?` | \| `number` \| `"static"` \| (`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"` | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | -| `structuralSharing?` | `boolean` \| (`oldData`: `unknown`, `newData`: `unknown`) => `unknown` | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | -| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | -| `throwOnError?` | \| `false` \| `true` \| (`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | +| `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. | +| `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | +| `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | +| `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | +| `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | +| `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | +| `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | +| `notifyOnChangeProps?` | \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"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"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. | +| `persister?` | (`queryFn`: (`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`NoInfer`\<`TQueryKey`\>, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. | +| `placeholderData?` | \| `NonFunctionGuard`\<`TQueryData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryData`\>, `TError`, `NonFunctionGuard`\<`TQueryData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. | +| `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: [`QueryFunctionContext`](../type-aliases/QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\>) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. | +| `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. | +| `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). | +| `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | +| `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency | +| `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. | +| `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value | +| `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. | +| `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. | +| `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | +| `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | +| `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. | +| `select?` | (`data`: `TQueryData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. | +| `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. | +| `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | +| `suspense?` | `boolean` | `false` | If set to `true`, the query will suspend when `status === 'pending'` and throw errors when `status === 'error'`. | +| `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md index b34a0fb97fb..f9407ba6d40 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md index aebb011fb68..c45d0e90b5f 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1030](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md index 65972cd1593..73ac2d290b1 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:998](https://github.com/TanStack/q | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md index 46605ef0bc4..12f242965db 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md @@ -23,28 +23,28 @@ Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/ | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) | -| `errorUpdateCount` | `number` | The sum of all errors. | - | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | -| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | -| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | -| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) | -| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | -| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | -| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | -| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) | -| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) | -| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | -| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) | -| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) | +| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | +| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `errorUpdateCount` | `number` | The sum of all errors. | - | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | +| `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | +| `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | +| `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | +| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | +| `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | +| `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | +| ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | +| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | +| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | +| `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | +| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | +| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryState.md b/docs/framework/vue/reference/interfaces/QueryState.md index 131d202908d..c001726f67e 100644 --- a/docs/framework/vue/reference/interfaces/QueryState.md +++ b/docs/framework/vue/reference/interfaces/QueryState.md @@ -22,15 +22,15 @@ that observer results (e.g. `QueryObserverResult`) are derived from. | Property | Type | Description | | ------ | ------ | ------ | -| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | -| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | -| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | -| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | -| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | -| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | -| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | -| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | -| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | -| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | -| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | -| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | +| `data` | `TData` \| `undefined` | The last successfully resolved data for the query. | +| `dataUpdateCount` | `number` | The number of times the query has successfully resolved. | +| `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | +| `error` | `TError` \| `null` | The error object for the query, if the last attempt resulted in an error. - Defaults to `null`. | +| `errorUpdateCount` | `number` | The sum of all errors, incremented every time the query resolves with an error. | +| `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | +| `fetchFailureCount` | `number` | The failure count for the current fetch. - Incremented every time the fetch fails. - Reset to `0` when the fetch succeeds. | +| `fetchFailureReason` | `TError` \| `null` | The reason the current fetch failed, as reported by the retryer. - Reset to `null` when the fetch succeeds. | +| `fetchMeta` | `FetchMeta` \| `null` | Metadata passed to the currently in-flight (or most recent) fetch, e.g. the `fetchMore` direction for infinite queries. | +| `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: the `queryFn` is currently executing. - `paused`: a fetch wanted to run but has been paused (see network mode). - `idle`: the query is not fetching. | +| `isInvalidated` | `boolean` | Whether the query has been marked as invalidated via `invalidate()`. - Reset to `false` whenever the query resolves successfully. | +| `status` | `"error"` \| `"pending"` \| `"success"` | The status of the query. - `pending` if there's no cached data and no attempt was finished yet. - `error` if the last attempt resulted in an error. - `success` if the query has data. | diff --git a/docs/framework/vue/reference/interfaces/RefetchOptions.md b/docs/framework/vue/reference/interfaces/RefetchOptions.md index 8acaa51413d..afc94272a2a 100644 --- a/docs/framework/vue/reference/interfaces/RefetchOptions.md +++ b/docs/framework/vue/reference/interfaces/RefetchOptions.md @@ -18,5 +18,5 @@ Defined in: [packages/query-core/src/types.ts:760](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md b/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md index 1f0c1e1212f..892dca5eb84 100644 --- a/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md +++ b/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md @@ -22,9 +22,9 @@ All provided filters must match; filters that are left unspecified are ignored. | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `exact?` | `boolean` | `undefined` | Match query key exactly | -| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | -| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | -| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | -| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | -| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | +| `exact?` | `boolean` | `undefined` | Match query key exactly | +| `fetchStatus?` | `"fetching"` \| `"paused"` \| `"idle"` | `undefined` | Include queries matching their fetchStatus | +| `predicate?` | (`query`: [`Query`](../classes/Query.md)) => `boolean` | `undefined` | Include queries matching this predicate function | +| `queryKey?` | `TQueryKey` \| `TuplePrefixes`\<`TQueryKey`\> | `undefined` | Include queries matching this query key | +| `stale?` | `boolean` | `undefined` | Include or exclude stale queries | +| `type?` | `QueryTypeFilter` | `'all'` | Filter to active queries, inactive queries or all queries | diff --git a/docs/framework/vue/reference/interfaces/ResetOptions.md b/docs/framework/vue/reference/interfaces/ResetOptions.md index 79f5a904a4e..8cb43030725 100644 --- a/docs/framework/vue/reference/interfaces/ResetOptions.md +++ b/docs/framework/vue/reference/interfaces/ResetOptions.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:792](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `cancelRefetch?` | `boolean` | `true` | If set to `true`, a currently running request will be cancelled before a new request is made If set to `false`, no refetch will be made if there is already a request running. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/vue/reference/interfaces/ResultOptions.md b/docs/framework/vue/reference/interfaces/ResultOptions.md index ef37ad867ad..cde1a9d89c0 100644 --- a/docs/framework/vue/reference/interfaces/ResultOptions.md +++ b/docs/framework/vue/reference/interfaces/ResultOptions.md @@ -15,4 +15,4 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | Property | Type | Default value | Description | | ------ | ------ | ------ | ------ | -| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | +| `throwOnError?` | `boolean` | `false` | If set to `true`, the method throws if any of the underlying query refetch tasks fail. If set to `false`, failed refetches are swallowed and not surfaced to the caller. | diff --git a/docs/framework/vue/reference/interfaces/SetDataOptions.md b/docs/framework/vue/reference/interfaces/SetDataOptions.md index a5df3498df2..5aa1894d14d 100644 --- a/docs/framework/vue/reference/interfaces/SetDataOptions.md +++ b/docs/framework/vue/reference/interfaces/SetDataOptions.md @@ -13,4 +13,4 @@ omit it to use the current time. | Property | Type | | ------ | ------ | -| `updatedAt?` | `number` | +| `updatedAt?` | `number` | diff --git a/docs/framework/vue/reference/interfaces/TimeoutManager.md b/docs/framework/vue/reference/interfaces/TimeoutManager.md index 317213619d5..164487133a6 100644 --- a/docs/framework/vue/reference/interfaces/TimeoutManager.md +++ b/docs/framework/vue/reference/interfaces/TimeoutManager.md @@ -37,7 +37,7 @@ returned by `setInterval`. ##### intervalId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -58,7 +58,9 @@ timeoutManager.clearInterval(intervalId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) +```ts +Omit.clearInterval +``` *** @@ -78,7 +80,7 @@ timer ID returned by `setTimeout`. ##### timeoutId -[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` #### Returns @@ -99,7 +101,9 @@ timeoutManager.clearTimeout(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) +```ts +Omit.clearTimeout +``` *** @@ -144,7 +148,9 @@ const intervalId = timeoutManager.setInterval( #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) +```ts +Omit.setInterval +``` *** @@ -192,7 +198,9 @@ const timeoutIdNumber: number = Number(timeoutId) #### Implementation of -[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) +```ts +Omit.setTimeout +``` *** diff --git a/docs/framework/vue/reference/type-aliases/AnyDataTag.md b/docs/framework/vue/reference/type-aliases/AnyDataTag.md index a1a09d3344a..63e2af07459 100644 --- a/docs/framework/vue/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/vue/reference/type-aliases/AnyDataTag.md @@ -13,5 +13,5 @@ Defined in: [packages/query-core/src/types.ts:93](https://github.com/TanStack/qu | Property | Type | | ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| `[dataTagErrorSymbol]` | `any` | +| `[dataTagSymbol]` | `any` | diff --git a/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index 396b5cee594..c13085ae60c 100644 --- a/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -19,7 +19,7 @@ never `undefined` (unless a `select` changes `TData` to include `undefined`). ```ts initialData: | NonUndefinedGuard> -| () => NonUndefinedGuard>; + | (() => NonUndefinedGuard>); ``` If set, this value will be used as the initial data for the query cache (as long as the query hasn't been diff --git a/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md index 2b56ecd0d4f..54f4f67b510 100644 --- a/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md +++ b/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/query-core/src/types.ts:687](https://github.com/TanStack/q ### ~~revalidateIfStale?~~ ```ts -optional revalidateIfStale: boolean; +optional revalidateIfStale?: boolean; ``` ## Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md b/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md index be626e866be..be4bb7c20a0 100644 --- a/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md @@ -13,6 +13,6 @@ Defined in: [packages/query-core/src/types.ts:1259](https://github.com/TanStack/ | Property | Type | | ------ | ------ | -| `client` | `QueryClient` | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| `client` | `QueryClient` | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | diff --git a/docs/framework/vue/reference/type-aliases/MutationScope.md b/docs/framework/vue/reference/type-aliases/MutationScope.md index dc6ac23ed0b..3fdf1dff0a4 100644 --- a/docs/framework/vue/reference/type-aliases/MutationScope.md +++ b/docs/framework/vue/reference/type-aliases/MutationScope.md @@ -17,4 +17,4 @@ state and resume automatically when their turn comes. Mutations with no scope al | Property | Type | | ------ | ------ | -| `id` | `string` | +| `id` | `string` | diff --git a/docs/framework/vue/reference/type-aliases/MutationStateOptions.md b/docs/framework/vue/reference/type-aliases/MutationStateOptions.md index 187c537c904..6a77bf414e4 100644 --- a/docs/framework/vue/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/vue/reference/type-aliases/MutationStateOptions.md @@ -23,5 +23,5 @@ Defined in: [packages/vue-query/src/useMutationState.ts:91](https://github.com/T | Property | Type | | ------ | ------ | -| `filters?` | `VueMutationFilters` | -| `select?` | (`mutation`: `TMutation`) => `TResult` | +| `filters?` | `VueMutationFilters` | +| `select?` | (`mutation`: `TMutation`) => `TResult` | diff --git a/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md index 9191c25c7d9..9b658cb5e6b 100644 --- a/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md +++ b/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md @@ -8,10 +8,10 @@ type NotifyOnChangeProps = | keyof InfiniteQueryObserverResult[] | "all" | undefined - | () => + | (() => | keyof InfiniteQueryObserverResult[] | "all" - | undefined; + | undefined); ``` Defined in: [packages/query-core/src/types.ts:270](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L270) diff --git a/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md index d35d6161a39..fc88186764a 100644 --- a/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md +++ b/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md @@ -33,11 +33,12 @@ Defined in: [packages/query-core/src/types.ts:209](https://github.com/TanStack/q ### previousData -`TQueryData` | `undefined` +`TQueryData` \| `undefined` ### previousQuery -[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + \| [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + \| `undefined` ## Returns diff --git a/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md b/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md index 45daab83127..5a63f8dae29 100644 --- a/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md +++ b/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md @@ -6,7 +6,7 @@ title: QueryBooleanOption ```ts type QueryBooleanOption = | boolean - | (query: Query) => boolean; + | ((query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L149) diff --git a/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md index fdefe2fbead..eb5509f40e1 100644 --- a/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md @@ -27,4 +27,4 @@ Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/q | Property | Type | | ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | diff --git a/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md b/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md index 761e1af5402..ba9b538fa66 100644 --- a/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md +++ b/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md @@ -6,7 +6,7 @@ title: StaleTimeFunction ```ts type StaleTimeFunction = | number | "static" - | (query: Query) => number | "static"; + | ((query: Query) => number | "static"); ``` Defined in: [packages/query-core/src/types.ts:139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L139) diff --git a/docs/framework/vue/reference/type-aliases/ThrowOnError.md b/docs/framework/vue/reference/type-aliases/ThrowOnError.md index ffed6038ff5..40b1fcd4739 100644 --- a/docs/framework/vue/reference/type-aliases/ThrowOnError.md +++ b/docs/framework/vue/reference/type-aliases/ThrowOnError.md @@ -6,7 +6,7 @@ title: ThrowOnError ```ts type ThrowOnError = | boolean - | (error: TError, query: Query) => boolean; + | ((error: TError, query: Query) => boolean); ``` Defined in: [packages/query-core/src/types.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L420) diff --git a/docs/framework/vue/reference/type-aliases/TimeoutProvider.md b/docs/framework/vue/reference/type-aliases/TimeoutProvider.md index e74ad3a36d5..2ba02bd2c27 100644 --- a/docs/framework/vue/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/vue/reference/type-aliases/TimeoutProvider.md @@ -27,7 +27,7 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. | Property | Modifier | Type | | ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | diff --git a/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index b92014e908c..b2827878a91 100644 --- a/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -17,7 +17,7 @@ may be `undefined` while the query is `pending`. ### initialData? ```ts -optional initialData: undefined; +optional initialData?: undefined; ``` ## Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/Updater.md b/docs/framework/vue/reference/type-aliases/Updater.md index 86d38355a0b..6b5ab7f7622 100644 --- a/docs/framework/vue/reference/type-aliases/Updater.md +++ b/docs/framework/vue/reference/type-aliases/Updater.md @@ -4,7 +4,7 @@ title: Updater --- ```ts -type Updater = TOutput | (input: TInput) => TOutput; +type Updater = TOutput | ((input: TInput) => TOutput); ``` Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) diff --git a/docs/framework/vue/reference/type-aliases/UseIsFetchingFilters.md b/docs/framework/vue/reference/type-aliases/UseIsFetchingFilters.md index 14ea1f8e93f..c2605f33786 100644 --- a/docs/framework/vue/reference/type-aliases/UseIsFetchingFilters.md +++ b/docs/framework/vue/reference/type-aliases/UseIsFetchingFilters.md @@ -6,7 +6,7 @@ title: UseIsFetchingFilters ```ts type UseIsFetchingFilters = | MaybeRefDeep -| () => MaybeRefDeep; + | (() => MaybeRefDeep); ``` Defined in: [packages/vue-query/src/useIsFetching.ts:9](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L9) diff --git a/docs/framework/vue/reference/type-aliases/UseIsMutatingFilters.md b/docs/framework/vue/reference/type-aliases/UseIsMutatingFilters.md index dd14e5e1a4e..c9bdc22a079 100644 --- a/docs/framework/vue/reference/type-aliases/UseIsMutatingFilters.md +++ b/docs/framework/vue/reference/type-aliases/UseIsMutatingFilters.md @@ -4,7 +4,7 @@ title: UseIsMutatingFilters --- ```ts -type UseIsMutatingFilters = VueMutationFilters | () => VueMutationFilters; +type UseIsMutatingFilters = VueMutationFilters | (() => VueMutationFilters); ``` Defined in: [packages/vue-query/src/useMutationState.ts:23](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L23) diff --git a/docs/framework/vue/reference/type-aliases/UseMutationOptions.md b/docs/framework/vue/reference/type-aliases/UseMutationOptions.md index c00317b956e..bf432876ac0 100644 --- a/docs/framework/vue/reference/type-aliases/UseMutationOptions.md +++ b/docs/framework/vue/reference/type-aliases/UseMutationOptions.md @@ -6,7 +6,7 @@ title: UseMutationOptions ```ts type UseMutationOptions = | MaybeRefDeep> -| () => MaybeRefDeep>; + | (() => MaybeRefDeep>); ``` Defined in: [packages/vue-query/src/useMutation.ts:31](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L31) diff --git a/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md b/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md index 1a0493ab1c9..fbd06625477 100644 --- a/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/vue-query/src/usePrefetchInfiniteQuery.ts:16](https://gith ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken>; +optional queryFn?: Exclude["queryFn"], SkipToken>; ``` ## Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/UsePrefetchQueryOptions.md b/docs/framework/vue/reference/type-aliases/UsePrefetchQueryOptions.md index 555695eb492..a42bbbf9bdc 100644 --- a/docs/framework/vue/reference/type-aliases/UsePrefetchQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/UsePrefetchQueryOptions.md @@ -14,7 +14,7 @@ Defined in: [packages/vue-query/src/usePrefetchQuery.ts:15](https://github.com/T ### queryFn? ```ts -optional queryFn: Exclude["queryFn"], SkipToken>; +optional queryFn?: Exclude["queryFn"], SkipToken>; ``` ## Type Parameters diff --git a/docs/framework/vue/reference/variables/VueQueryPlugin.md b/docs/framework/vue/reference/variables/VueQueryPlugin.md index 6005c1bff3e..0a371b05215 100644 --- a/docs/framework/vue/reference/variables/VueQueryPlugin.md +++ b/docs/framework/vue/reference/variables/VueQueryPlugin.md @@ -15,7 +15,7 @@ instead of a wrapping component. ## Type Declaration -### install() +### install ```ts install: (app: any, options: VueQueryPluginOptions) => void; @@ -27,7 +27,7 @@ install: (app: any, options: VueQueryPluginOptions) => void; `any` -##### options +##### options? [`VueQueryPluginOptions`](../type-aliases/VueQueryPluginOptions.md) = `{}` diff --git a/docs/framework/vue/reference/variables/environmentManager.md b/docs/framework/vue/reference/variables/environmentManager.md index 4f88d27d2a9..1b5f65b6a99 100644 --- a/docs/framework/vue/reference/variables/environmentManager.md +++ b/docs/framework/vue/reference/variables/environmentManager.md @@ -20,7 +20,7 @@ behave like a client. ## Type Declaration -### isServer() +### isServer ```ts isServer: () => boolean; diff --git a/docs/framework/vue/reference/variables/notifyManager.md b/docs/framework/vue/reference/variables/notifyManager.md index c2c071b42a5..abc590e3442 100644 --- a/docs/framework/vue/reference/variables/notifyManager.md +++ b/docs/framework/vue/reference/variables/notifyManager.md @@ -13,7 +13,7 @@ Handles scheduling and batching callbacks in TanStack Query. ## Type Declaration -### batch() +### batch ```ts readonly batch: (callback: () => T) => T; @@ -40,7 +40,7 @@ The return value of `callback` is passed through. `T` -### batchCalls() +### batchCalls ```ts readonly batchCalls: (callback: BatchCallsCallback) => BatchCallsCallback; @@ -64,7 +64,7 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> -### schedule() +### schedule ```ts schedule: (callback: NotifyCallback) => void; @@ -83,7 +83,7 @@ By default, the batch is run with a `setTimeout`, but this can be configured via `void` -### setBatchNotifyFunction() +### setBatchNotifyFunction ```ts readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; @@ -112,7 +112,7 @@ import { batch } from 'solid-js' notifyManager.setBatchNotifyFunction(batch) ``` -### setNotifyFunction() +### setNotifyFunction ```ts readonly setNotifyFunction: (fn: NotifyFunction) => void; @@ -131,7 +131,7 @@ This can be used to for example wrap notifications with `React.act` while runnin `void` -### setScheduler() +### setScheduler ```ts readonly setScheduler: (fn: ScheduleFunction) => void; From 593dd86b50cd4f7a48dc2997a0623bf811c90abd Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Sun, 4 Oct 2026 04:38:18 +0900 Subject: [PATCH 3/4] docs(framework/*/reference): regenerate reference docs --- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../reference/classes/MutationCache.md | 32 ++- .../reference/classes/MutationObserver.md | 30 ++- .../reference/classes/QueriesObserver.md | 41 +++- .../angular/reference/classes/Query.md | 80 +++++-- .../angular/reference/classes/QueryCache.md | 55 ++++- .../angular/reference/classes/QueryClient.md | 216 +++++++++++++++--- .../reference/classes/QueryObserver.md | 71 ++++-- .../angular/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../reference/interfaces/FocusManager.md | 23 +- .../reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../reference/variables/notifyManager.md | 16 +- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../lit/reference/classes/MutationCache.md | 32 ++- .../lit/reference/classes/MutationObserver.md | 30 ++- .../lit/reference/classes/QueriesObserver.md | 41 +++- docs/framework/lit/reference/classes/Query.md | 80 +++++-- .../lit/reference/classes/QueryCache.md | 55 ++++- .../lit/reference/classes/QueryClient.md | 216 +++++++++++++++--- .../lit/reference/classes/QueryObserver.md | 71 ++++-- .../lit/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../lit/reference/interfaces/FocusManager.md | 23 +- .../lit/reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../lit/reference/variables/notifyManager.md | 16 +- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../preact/reference/classes/MutationCache.md | 32 ++- .../reference/classes/MutationObserver.md | 30 ++- .../reference/classes/QueriesObserver.md | 41 +++- .../preact/reference/classes/Query.md | 80 +++++-- .../preact/reference/classes/QueryCache.md | 55 ++++- .../preact/reference/classes/QueryClient.md | 216 +++++++++++++++--- .../preact/reference/classes/QueryObserver.md | 71 ++++-- .../preact/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../reference/interfaces/FocusManager.md | 23 +- .../reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../reference/variables/notifyManager.md | 16 +- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../react/reference/classes/MutationCache.md | 32 ++- .../reference/classes/MutationObserver.md | 30 ++- .../reference/classes/QueriesObserver.md | 41 +++- .../react/reference/classes/Query.md | 80 +++++-- .../react/reference/classes/QueryCache.md | 55 ++++- .../react/reference/classes/QueryClient.md | 216 +++++++++++++++--- .../react/reference/classes/QueryObserver.md | 71 ++++-- .../react/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../reference/interfaces/FocusManager.md | 23 +- .../reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../reference/variables/notifyManager.md | 16 +- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../solid/reference/classes/MutationCache.md | 32 ++- .../reference/classes/MutationObserver.md | 30 ++- .../reference/classes/QueriesObserver.md | 41 +++- .../solid/reference/classes/Query.md | 80 +++++-- .../solid/reference/classes/QueryCache.md | 55 ++++- .../solid/reference/classes/QueryClient.md | 216 +++++++++++++++--- .../solid/reference/classes/QueryObserver.md | 71 ++++-- .../solid/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../reference/interfaces/FocusManager.md | 23 +- .../reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../reference/variables/notifyManager.md | 16 +- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../svelte/reference/classes/MutationCache.md | 32 ++- .../reference/classes/MutationObserver.md | 30 ++- .../reference/classes/QueriesObserver.md | 41 +++- .../svelte/reference/classes/Query.md | 80 +++++-- .../svelte/reference/classes/QueryCache.md | 55 ++++- .../svelte/reference/classes/QueryClient.md | 216 +++++++++++++++--- .../svelte/reference/classes/QueryObserver.md | 71 ++++-- .../svelte/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../reference/interfaces/FocusManager.md | 23 +- .../reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../reference/variables/notifyManager.md | 16 +- .../classes/InfiniteQueryObserver.md | 87 +++++-- .../vue/reference/classes/MutationCache.md | 26 ++- .../vue/reference/classes/MutationObserver.md | 30 ++- .../vue/reference/classes/QueriesObserver.md | 41 +++- docs/framework/vue/reference/classes/Query.md | 80 +++++-- .../vue/reference/classes/QueryCache.md | 49 +++- .../vue/reference/classes/QueryClient.md | 133 ++++++++++- .../vue/reference/classes/QueryObserver.md | 71 ++++-- .../vue/reference/functions/dehydrate.md | 9 +- .../functions/experimental_streamedQuery.md | 11 +- .../reference/functions/keepPreviousData.md | 6 +- .../reference/functions/shouldThrowError.md | 9 +- .../vue/reference/interfaces/FocusManager.md | 23 +- .../vue/reference/interfaces/OnlineManager.md | 21 +- .../reference/interfaces/TimeoutManager.md | 28 ++- .../vue/reference/variables/notifyManager.md | 16 +- 112 files changed, 3983 insertions(+), 1067 deletions(-) diff --git a/docs/framework/angular/reference/classes/InfiniteQueryObserver.md b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md index 1a70c8ebf7f..710bf14ae5c 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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) 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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -86,13 +86,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -114,7 +118,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -128,7 +132,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -144,6 +148,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -170,7 +176,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -192,7 +198,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -206,10 +212,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -232,7 +244,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -246,10 +258,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -272,7 +288,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -286,10 +302,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -312,7 +334,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -320,6 +342,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -332,7 +356,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -345,10 +369,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -361,7 +389,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -369,6 +397,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -378,24 +408,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -428,6 +463,8 @@ implementation. [`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -454,6 +491,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -466,7 +505,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -476,6 +515,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -513,7 +554,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -550,6 +591,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -591,7 +634,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -604,6 +647,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -633,10 +678,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -649,7 +698,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/MutationCache.md b/docs/framework/angular/reference/classes/MutationCache.md index 4b8f85cab33..9e7e7ed406c 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/src/mutationCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L123) The `MutationCache` is the storage for mutations. @@ -31,7 +31,7 @@ const unsubscribe = mutationCache.subscribe((event) => { 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -57,7 +57,7 @@ Subscribable.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) ## Methods @@ -67,7 +67,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -93,7 +93,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/src/mutationCache.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L300) 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. @@ -125,11 +125,15 @@ information about a mutation in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -150,7 +154,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] }) 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/src/mutationCache.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L331) 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. @@ -164,10 +168,14 @@ information about mutations in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -188,7 +196,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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -199,6 +207,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -215,7 +225,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -223,6 +233,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -237,7 +249,7 @@ Subscribable.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -253,6 +265,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/angular/reference/classes/MutationObserver.md b/docs/framework/angular/reference/classes/MutationObserver.md index 87c7814735b..13ec27342ff 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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/angular/reference/classes/QueriesObserver.md b/docs/framework/angular/reference/classes/QueriesObserver.md index 08c997c2d13..a05cddbc172 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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) 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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -79,7 +79,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -96,7 +96,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -106,6 +106,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -121,7 +123,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -131,6 +133,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -139,7 +143,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -153,14 +157,21 @@ wrap the results for property-access tracking. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -169,7 +180,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -178,6 +189,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -186,7 +199,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -194,6 +207,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -208,7 +223,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -221,10 +236,14 @@ observers are created and subscribed to for newly added queries. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -246,7 +265,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -262,6 +281,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/angular/reference/classes/Query.md b/docs/framework/angular/reference/classes/Query.md index c6b5f29ac9c..4bef73a69e0 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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. [`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/angular/reference/classes/QueryCache.md b/docs/framework/angular/reference/classes/QueryCache.md index b29348f1a4b..67d8c500d4a 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/src/queryCache.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L122) The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information, and state of the queries it contains. @@ -34,7 +34,7 @@ const unsubscribe = queryCache.subscribe((event) => { 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -60,7 +60,7 @@ Subscribable.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) ## Methods @@ -73,7 +73,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -104,18 +104,28 @@ the reactive `QueryObserver` machinery. [`QueryClient`](QueryClient.md) +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -135,7 +145,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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -161,7 +171,7 @@ find(filters: WithRequired, `"queryKey"`\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -217,7 +232,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) findAll(filters?: QueryFilters): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) +Defined in: [packages/query-core/src/queryCache.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L330) 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. @@ -231,10 +246,14 @@ information about queries in rare scenarios. [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -257,7 +276,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -288,11 +307,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -310,7 +333,7 @@ const query = queryCache.get(queryHash) getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -318,6 +341,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -334,7 +359,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -342,6 +367,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -356,7 +383,7 @@ Subscribable.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -369,6 +396,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -392,7 +421,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -408,6 +437,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/angular/reference/classes/QueryClient.md b/docs/framework/angular/reference/classes/QueryClient.md index 07781860817..4dee1d4851c 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/src/queryClient.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L78) `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 @@ -31,7 +31,7 @@ await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) 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/src/queryClient.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L88) #### Parameters @@ -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/src/queryClient.ts:459](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L459) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -72,14 +72,22 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### cancelOptions? [`CancelOptions`](../interfaces/CancelOptions.md) = `{}` +Passed to each matched query's cancellation. `revert` defaults to +`true`. + #### Returns `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -94,7 +102,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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -119,7 +127,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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -138,10 +146,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + *** ### defaultQueryOptions() @@ -152,7 +164,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -192,10 +204,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + *** ### ~~ensureInfiniteQueryData()~~ @@ -204,7 +221,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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -234,10 +251,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -250,7 +273,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/src/queryClient.ts:205](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L205) #### Type Parameters @@ -276,10 +299,16 @@ Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanS [`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options. If the query has no cached data yet, it is fetched with +these options. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached data, or to the fetched data if nothing was +cached yet. + #### Deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -292,7 +321,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/src/queryClient.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L746) #### Type Parameters @@ -322,10 +351,16 @@ Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached or fetched [InfiniteData](../interfaces/InfiniteData.md), or rejects with +the fetch error. + #### Deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. @@ -338,7 +373,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/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643) #### Type Parameters @@ -368,10 +403,16 @@ Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached or fetched data, or rejects with the fetch +error. + #### Deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. @@ -384,7 +425,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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -393,6 +434,8 @@ Returns the default options that were set when creating the client, or via [`DefaultOptions`](../interfaces/DefaultOptions.md) +The client's current default options. + #### Example ```ts @@ -410,7 +453,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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -418,6 +461,8 @@ Returns the mutation cache this client is connected to. [`MutationCache`](MutationCache.md) +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -436,7 +481,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/src/queryClient.ts:1015](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1015) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -448,10 +493,15 @@ defaults match, they are merged together in registration order. readonly `unknown`[] +The mutation key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -466,7 +516,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/src/queryClient.ts:251](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L251) 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 @@ -494,6 +544,8 @@ contents. `TQueryFilters` +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -518,7 +570,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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -526,6 +578,8 @@ Returns the query cache this client is connected to. [`QueryCache`](QueryCache.md) +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -544,7 +598,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/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) 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. @@ -572,6 +626,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + #### Returns `TInferredQueryFnData` \| `undefined` @@ -590,7 +646,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/src/queryClient.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L955) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -602,10 +658,15 @@ match, they are merged together in registration order. readonly `unknown`[] +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -622,7 +683,7 @@ getQueryState \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -675,7 +740,7 @@ console.log(state?.dataUpdatedAt) infiniteQuery(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/src/queryClient.ts:716](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L716) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -715,10 +780,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -738,7 +809,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/src/queryClient.ts:492](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L492) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -759,14 +830,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? [`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -781,7 +861,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/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) 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 @@ -799,10 +879,15 @@ loading more infinite query results. `TQueryFilters` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -819,7 +904,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/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -836,10 +921,15 @@ matching a set of filters. `TMutationFilters` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -856,7 +946,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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -875,7 +965,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/src/queryClient.ts:772](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L772) #### Type Parameters @@ -905,10 +995,15 @@ Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -921,7 +1016,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/src/queryClient.ts:680](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L680) #### Type Parameters @@ -947,10 +1042,15 @@ Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -963,7 +1063,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/src/queryClient.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L593) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1018,10 +1118,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -1040,7 +1146,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/src/queryClient.ts:533](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L533) 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 @@ -1062,14 +1168,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1085,7 +1199,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/src/queryClient.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L395) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1104,6 +1218,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1122,7 +1239,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/src/queryClient.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L420) 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 @@ -1140,14 +1257,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? [`ResetOptions`](../interfaces/ResetOptions.md) +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1162,7 +1287,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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1171,6 +1296,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1188,7 +1315,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/src/queryClient.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L903) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1199,6 +1326,8 @@ default options. [`DefaultOptions`](../interfaces/DefaultOptions.md) +The new default options for queries and mutations. + #### Returns `void` @@ -1228,7 +1357,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/src/queryClient.ts:985](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L985) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1258,10 +1387,14 @@ matters when several registered defaults match the same mutation key. readonly `unknown`[] +The mutation key that mutation keys are partially matched against. + ##### options [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +The default options applied to matching mutations. + #### Returns `void` @@ -1287,7 +1420,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/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L336) 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 @@ -1310,14 +1443,21 @@ filters are updated; no new cache entries are created. Internally this calls `TQueryFilters` +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? [`SetDataOptions`](../interfaces/SetDataOptions.md) +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -1344,7 +1484,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/src/queryClient.ts:283](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L283) 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; @@ -1413,7 +1553,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/src/queryClient.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L923) Sets default options for queries whose query key partially matches the given `queryKey`. @@ -1446,10 +1586,14 @@ after more generic ones so they take precedence. readonly `unknown`[] +The query key that query keys are partially matched against. + ##### options `Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -1470,7 +1614,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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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 845acfe60cb..78898c0b788 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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) 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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -93,7 +93,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -103,7 +103,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -121,7 +121,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -135,10 +135,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -157,7 +161,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -165,6 +169,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -173,7 +179,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -184,6 +190,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -199,7 +207,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -212,10 +220,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -224,7 +236,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -232,6 +244,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -243,24 +257,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -276,7 +295,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -290,6 +309,8 @@ refetch-interval timers as needed. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -320,6 +341,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -328,7 +351,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -338,6 +361,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -346,7 +371,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -362,6 +387,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -413,7 +440,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -450,6 +477,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -487,7 +516,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -500,6 +529,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -529,10 +560,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -541,7 +576,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/dehydrate.md b/docs/framework/angular/reference/functions/dehydrate.md index 4999cadaf08..772a36e9366 100644 --- a/docs/framework/angular/reference/functions/dehydrate.md +++ b/docs/framework/angular/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/angular/reference/functions/experimental_streamedQuery.md b/docs/framework/angular/reference/functions/experimental_streamedQuery.md index 791a80817f2..35dd7c09176 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(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -30,14 +30,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/angular/reference/functions/keepPreviousData.md b/docs/framework/angular/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/angular/reference/functions/keepPreviousData.md +++ b/docs/framework/angular/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/angular/reference/functions/shouldThrowError.md b/docs/framework/angular/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/angular/reference/functions/shouldThrowError.md +++ b/docs/framework/angular/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/angular/reference/interfaces/FocusManager.md b/docs/framework/angular/reference/interfaces/FocusManager.md index 3d59e85c451..95250b0999f 100644 --- a/docs/framework/angular/reference/interfaces/FocusManager.md +++ b/docs/framework/angular/reference/interfaces/FocusManager.md @@ -21,7 +21,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -29,6 +29,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -43,7 +45,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -51,6 +53,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -59,7 +63,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -75,7 +79,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -89,6 +93,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -120,7 +127,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -131,6 +138,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -158,7 +167,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -174,6 +183,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/angular/reference/interfaces/OnlineManager.md b/docs/framework/angular/reference/interfaces/OnlineManager.md index 7e97e7bc137..e3e17cd2a1b 100644 --- a/docs/framework/angular/reference/interfaces/OnlineManager.md +++ b/docs/framework/angular/reference/interfaces/OnlineManager.md @@ -25,7 +25,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -33,6 +33,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -47,7 +49,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -55,6 +57,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -63,7 +67,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -76,6 +80,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -101,7 +108,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -111,6 +118,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -135,7 +144,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -151,6 +160,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/angular/reference/interfaces/TimeoutManager.md b/docs/framework/angular/reference/interfaces/TimeoutManager.md index 164487133a6..06477f667a2 100644 --- a/docs/framework/angular/reference/interfaces/TimeoutManager.md +++ b/docs/framework/angular/reference/interfaces/TimeoutManager.md @@ -7,7 +7,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -27,7 +27,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -39,6 +39,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -70,7 +72,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -82,6 +84,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -113,7 +117,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -127,14 +131,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -160,7 +170,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -175,14 +185,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -238,6 +254,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/angular/reference/variables/notifyManager.md b/docs/framework/angular/reference/variables/notifyManager.md index abc590e3442..1358af7c7d4 100644 --- a/docs/framework/angular/reference/variables/notifyManager.md +++ b/docs/framework/angular/reference/variables/notifyManager.md @@ -7,7 +7,7 @@ title: notifyManager const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -36,10 +36,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -60,10 +64,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -99,6 +107,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -127,6 +137,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -146,6 +158,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` diff --git a/docs/framework/lit/reference/classes/InfiniteQueryObserver.md b/docs/framework/lit/reference/classes/InfiniteQueryObserver.md index 13c5e088537..497484737a5 100644 --- a/docs/framework/lit/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/lit/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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) 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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -86,13 +86,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -114,7 +118,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -128,7 +132,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -144,6 +148,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -170,7 +176,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -192,7 +198,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -206,10 +212,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -232,7 +244,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -246,10 +258,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -272,7 +288,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -286,10 +302,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -312,7 +334,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -320,6 +342,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -332,7 +356,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -345,10 +369,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -361,7 +389,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -369,6 +397,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -378,24 +408,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -428,6 +463,8 @@ implementation. [`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -454,6 +491,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -466,7 +505,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -476,6 +515,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -513,7 +554,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -550,6 +591,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -591,7 +634,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -604,6 +647,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -633,10 +678,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -649,7 +698,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/lit/reference/classes/MutationCache.md b/docs/framework/lit/reference/classes/MutationCache.md index 25f3b785266..4b2c045a81d 100644 --- a/docs/framework/lit/reference/classes/MutationCache.md +++ b/docs/framework/lit/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/src/mutationCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L123) The `MutationCache` is the storage for mutations. @@ -31,7 +31,7 @@ const unsubscribe = mutationCache.subscribe((event) => { 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -57,7 +57,7 @@ Subscribable.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) ## Methods @@ -67,7 +67,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -93,7 +93,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/src/mutationCache.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L300) 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. @@ -125,11 +125,15 @@ information about a mutation in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -150,7 +154,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] }) 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/src/mutationCache.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L331) 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. @@ -164,10 +168,14 @@ information about mutations in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -188,7 +196,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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -199,6 +207,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -215,7 +225,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -223,6 +233,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -237,7 +249,7 @@ Subscribable.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -253,6 +265,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/lit/reference/classes/MutationObserver.md b/docs/framework/lit/reference/classes/MutationObserver.md index 87c7814735b..13ec27342ff 100644 --- a/docs/framework/lit/reference/classes/MutationObserver.md +++ b/docs/framework/lit/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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/lit/reference/classes/QueriesObserver.md b/docs/framework/lit/reference/classes/QueriesObserver.md index 74f877cc70d..e4f122f75c9 100644 --- a/docs/framework/lit/reference/classes/QueriesObserver.md +++ b/docs/framework/lit/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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) 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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -79,7 +79,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -96,7 +96,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -106,6 +106,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -121,7 +123,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -131,6 +133,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -139,7 +143,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -153,14 +157,21 @@ wrap the results for property-access tracking. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -169,7 +180,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -178,6 +189,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -186,7 +199,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -194,6 +207,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -208,7 +223,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -221,10 +236,14 @@ observers are created and subscribed to for newly added queries. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -246,7 +265,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -262,6 +281,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/lit/reference/classes/Query.md b/docs/framework/lit/reference/classes/Query.md index c6b5f29ac9c..4bef73a69e0 100644 --- a/docs/framework/lit/reference/classes/Query.md +++ b/docs/framework/lit/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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. [`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/lit/reference/classes/QueryCache.md b/docs/framework/lit/reference/classes/QueryCache.md index 3a267e7bb1b..af11e6a88da 100644 --- a/docs/framework/lit/reference/classes/QueryCache.md +++ b/docs/framework/lit/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/src/queryCache.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L122) The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information, and state of the queries it contains. @@ -34,7 +34,7 @@ const unsubscribe = queryCache.subscribe((event) => { 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -60,7 +60,7 @@ Subscribable.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) ## Methods @@ -73,7 +73,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -104,18 +104,28 @@ the reactive `QueryObserver` machinery. [`QueryClient`](QueryClient.md) +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -135,7 +145,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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -161,7 +171,7 @@ find(filters: WithRequired, `"queryKey"`\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -217,7 +232,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) findAll(filters?: QueryFilters): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) +Defined in: [packages/query-core/src/queryCache.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L330) 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. @@ -231,10 +246,14 @@ information about queries in rare scenarios. [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -257,7 +276,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -288,11 +307,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -310,7 +333,7 @@ const query = queryCache.get(queryHash) getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -318,6 +341,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -334,7 +359,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -342,6 +367,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -356,7 +383,7 @@ Subscribable.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -369,6 +396,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -392,7 +421,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -408,6 +437,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/lit/reference/classes/QueryClient.md b/docs/framework/lit/reference/classes/QueryClient.md index e24c8c646ff..d58920734b4 100644 --- a/docs/framework/lit/reference/classes/QueryClient.md +++ b/docs/framework/lit/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/src/queryClient.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L78) `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 @@ -31,7 +31,7 @@ await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) 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/src/queryClient.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L88) #### Parameters @@ -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/src/queryClient.ts:459](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L459) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -72,14 +72,22 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### cancelOptions? [`CancelOptions`](../interfaces/CancelOptions.md) = `{}` +Passed to each matched query's cancellation. `revert` defaults to +`true`. + #### Returns `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -94,7 +102,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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -119,7 +127,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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -138,10 +146,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + *** ### defaultQueryOptions() @@ -152,7 +164,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -192,10 +204,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + *** ### ~~ensureInfiniteQueryData()~~ @@ -204,7 +221,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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -234,10 +251,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -250,7 +273,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/src/queryClient.ts:205](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L205) #### Type Parameters @@ -276,10 +299,16 @@ Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanS [`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options. If the query has no cached data yet, it is fetched with +these options. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached data, or to the fetched data if nothing was +cached yet. + #### Deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -292,7 +321,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/src/queryClient.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L746) #### Type Parameters @@ -322,10 +351,16 @@ Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached or fetched [InfiniteData](../interfaces/InfiniteData.md), or rejects with +the fetch error. + #### Deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. @@ -338,7 +373,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/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643) #### Type Parameters @@ -368,10 +403,16 @@ Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached or fetched data, or rejects with the fetch +error. + #### Deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. @@ -384,7 +425,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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -393,6 +434,8 @@ Returns the default options that were set when creating the client, or via [`DefaultOptions`](../interfaces/DefaultOptions.md) +The client's current default options. + #### Example ```ts @@ -410,7 +453,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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -418,6 +461,8 @@ Returns the mutation cache this client is connected to. [`MutationCache`](MutationCache.md) +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -436,7 +481,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/src/queryClient.ts:1015](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1015) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -448,10 +493,15 @@ defaults match, they are merged together in registration order. readonly `unknown`[] +The mutation key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -466,7 +516,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/src/queryClient.ts:251](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L251) 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 @@ -494,6 +544,8 @@ contents. `TQueryFilters` +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -518,7 +570,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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -526,6 +578,8 @@ Returns the query cache this client is connected to. [`QueryCache`](QueryCache.md) +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -544,7 +598,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/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) 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. @@ -572,6 +626,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + #### Returns `TInferredQueryFnData` \| `undefined` @@ -590,7 +646,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/src/queryClient.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L955) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -602,10 +658,15 @@ match, they are merged together in registration order. readonly `unknown`[] +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -622,7 +683,7 @@ getQueryState \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -675,7 +740,7 @@ console.log(state?.dataUpdatedAt) infiniteQuery(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/src/queryClient.ts:716](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L716) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -715,10 +780,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -738,7 +809,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/src/queryClient.ts:492](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L492) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -759,14 +830,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? [`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -781,7 +861,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/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) 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 @@ -799,10 +879,15 @@ loading more infinite query results. `TQueryFilters` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -819,7 +904,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/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -836,10 +921,15 @@ matching a set of filters. `TMutationFilters` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -856,7 +946,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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -875,7 +965,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/src/queryClient.ts:772](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L772) #### Type Parameters @@ -905,10 +995,15 @@ Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -921,7 +1016,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/src/queryClient.ts:680](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L680) #### Type Parameters @@ -947,10 +1042,15 @@ Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -963,7 +1063,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/src/queryClient.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L593) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1018,10 +1118,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -1040,7 +1146,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/src/queryClient.ts:533](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L533) 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 @@ -1062,14 +1168,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1085,7 +1199,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/src/queryClient.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L395) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1104,6 +1218,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1122,7 +1239,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/src/queryClient.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L420) 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 @@ -1140,14 +1257,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? [`ResetOptions`](../interfaces/ResetOptions.md) +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1162,7 +1287,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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1171,6 +1296,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1188,7 +1315,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/src/queryClient.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L903) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1199,6 +1326,8 @@ default options. [`DefaultOptions`](../interfaces/DefaultOptions.md) +The new default options for queries and mutations. + #### Returns `void` @@ -1228,7 +1357,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/src/queryClient.ts:985](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L985) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1258,10 +1387,14 @@ matters when several registered defaults match the same mutation key. readonly `unknown`[] +The mutation key that mutation keys are partially matched against. + ##### options [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +The default options applied to matching mutations. + #### Returns `void` @@ -1287,7 +1420,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/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L336) 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 @@ -1310,14 +1443,21 @@ filters are updated; no new cache entries are created. Internally this calls `TQueryFilters` +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? [`SetDataOptions`](../interfaces/SetDataOptions.md) +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -1344,7 +1484,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/src/queryClient.ts:283](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L283) 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; @@ -1413,7 +1553,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/src/queryClient.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L923) Sets default options for queries whose query key partially matches the given `queryKey`. @@ -1446,10 +1586,14 @@ after more generic ones so they take precedence. readonly `unknown`[] +The query key that query keys are partially matched against. + ##### options `Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -1470,7 +1614,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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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/lit/reference/classes/QueryObserver.md b/docs/framework/lit/reference/classes/QueryObserver.md index 5f4c6d7ac96..7f9ba3656ba 100644 --- a/docs/framework/lit/reference/classes/QueryObserver.md +++ b/docs/framework/lit/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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) 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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -93,7 +93,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -103,7 +103,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -121,7 +121,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -135,10 +135,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -157,7 +161,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -165,6 +169,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -173,7 +179,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -184,6 +190,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -199,7 +207,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -212,10 +220,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -224,7 +236,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -232,6 +244,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -243,24 +257,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -276,7 +295,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -290,6 +309,8 @@ refetch-interval timers as needed. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -320,6 +341,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -328,7 +351,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -338,6 +361,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -346,7 +371,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -362,6 +387,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -413,7 +440,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -450,6 +477,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -487,7 +516,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -500,6 +529,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -529,10 +560,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -541,7 +576,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/lit/reference/functions/dehydrate.md b/docs/framework/lit/reference/functions/dehydrate.md index 4999cadaf08..772a36e9366 100644 --- a/docs/framework/lit/reference/functions/dehydrate.md +++ b/docs/framework/lit/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/lit/reference/functions/experimental_streamedQuery.md b/docs/framework/lit/reference/functions/experimental_streamedQuery.md index 791a80817f2..35dd7c09176 100644 --- a/docs/framework/lit/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/lit/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(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -30,14 +30,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/lit/reference/functions/keepPreviousData.md b/docs/framework/lit/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/lit/reference/functions/keepPreviousData.md +++ b/docs/framework/lit/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/lit/reference/functions/shouldThrowError.md b/docs/framework/lit/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/lit/reference/functions/shouldThrowError.md +++ b/docs/framework/lit/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/lit/reference/interfaces/FocusManager.md b/docs/framework/lit/reference/interfaces/FocusManager.md index 3d59e85c451..95250b0999f 100644 --- a/docs/framework/lit/reference/interfaces/FocusManager.md +++ b/docs/framework/lit/reference/interfaces/FocusManager.md @@ -21,7 +21,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -29,6 +29,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -43,7 +45,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -51,6 +53,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -59,7 +63,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -75,7 +79,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -89,6 +93,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -120,7 +127,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -131,6 +138,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -158,7 +167,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -174,6 +183,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/lit/reference/interfaces/OnlineManager.md b/docs/framework/lit/reference/interfaces/OnlineManager.md index 7e97e7bc137..e3e17cd2a1b 100644 --- a/docs/framework/lit/reference/interfaces/OnlineManager.md +++ b/docs/framework/lit/reference/interfaces/OnlineManager.md @@ -25,7 +25,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -33,6 +33,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -47,7 +49,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -55,6 +57,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -63,7 +67,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -76,6 +80,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -101,7 +108,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -111,6 +118,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -135,7 +144,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -151,6 +160,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/lit/reference/interfaces/TimeoutManager.md b/docs/framework/lit/reference/interfaces/TimeoutManager.md index 164487133a6..06477f667a2 100644 --- a/docs/framework/lit/reference/interfaces/TimeoutManager.md +++ b/docs/framework/lit/reference/interfaces/TimeoutManager.md @@ -7,7 +7,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -27,7 +27,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -39,6 +39,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -70,7 +72,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -82,6 +84,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -113,7 +117,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -127,14 +131,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -160,7 +170,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -175,14 +185,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -238,6 +254,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/lit/reference/variables/notifyManager.md b/docs/framework/lit/reference/variables/notifyManager.md index abc590e3442..1358af7c7d4 100644 --- a/docs/framework/lit/reference/variables/notifyManager.md +++ b/docs/framework/lit/reference/variables/notifyManager.md @@ -7,7 +7,7 @@ title: notifyManager const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -36,10 +36,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -60,10 +64,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -99,6 +107,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -127,6 +137,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -146,6 +158,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` diff --git a/docs/framework/preact/reference/classes/InfiniteQueryObserver.md b/docs/framework/preact/reference/classes/InfiniteQueryObserver.md index 1a70c8ebf7f..710bf14ae5c 100644 --- a/docs/framework/preact/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/preact/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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) 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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -86,13 +86,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -114,7 +118,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -128,7 +132,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -144,6 +148,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -170,7 +176,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -192,7 +198,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -206,10 +212,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -232,7 +244,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -246,10 +258,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -272,7 +288,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -286,10 +302,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -312,7 +334,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -320,6 +342,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -332,7 +356,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -345,10 +369,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -361,7 +389,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -369,6 +397,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -378,24 +408,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -428,6 +463,8 @@ implementation. [`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -454,6 +491,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -466,7 +505,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -476,6 +515,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -513,7 +554,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -550,6 +591,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -591,7 +634,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -604,6 +647,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -633,10 +678,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -649,7 +698,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/preact/reference/classes/MutationCache.md b/docs/framework/preact/reference/classes/MutationCache.md index 4b8f85cab33..9e7e7ed406c 100644 --- a/docs/framework/preact/reference/classes/MutationCache.md +++ b/docs/framework/preact/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/src/mutationCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L123) The `MutationCache` is the storage for mutations. @@ -31,7 +31,7 @@ const unsubscribe = mutationCache.subscribe((event) => { 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -57,7 +57,7 @@ Subscribable.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) ## Methods @@ -67,7 +67,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -93,7 +93,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/src/mutationCache.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L300) 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. @@ -125,11 +125,15 @@ information about a mutation in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -150,7 +154,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] }) 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/src/mutationCache.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L331) 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. @@ -164,10 +168,14 @@ information about mutations in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -188,7 +196,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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -199,6 +207,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -215,7 +225,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -223,6 +233,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -237,7 +249,7 @@ Subscribable.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -253,6 +265,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/preact/reference/classes/MutationObserver.md b/docs/framework/preact/reference/classes/MutationObserver.md index 87c7814735b..13ec27342ff 100644 --- a/docs/framework/preact/reference/classes/MutationObserver.md +++ b/docs/framework/preact/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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/preact/reference/classes/QueriesObserver.md b/docs/framework/preact/reference/classes/QueriesObserver.md index 08c997c2d13..a05cddbc172 100644 --- a/docs/framework/preact/reference/classes/QueriesObserver.md +++ b/docs/framework/preact/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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) 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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -79,7 +79,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -96,7 +96,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -106,6 +106,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -121,7 +123,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -131,6 +133,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -139,7 +143,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -153,14 +157,21 @@ wrap the results for property-access tracking. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -169,7 +180,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -178,6 +189,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -186,7 +199,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -194,6 +207,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -208,7 +223,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -221,10 +236,14 @@ observers are created and subscribed to for newly added queries. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -246,7 +265,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -262,6 +281,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/preact/reference/classes/Query.md b/docs/framework/preact/reference/classes/Query.md index c6b5f29ac9c..4bef73a69e0 100644 --- a/docs/framework/preact/reference/classes/Query.md +++ b/docs/framework/preact/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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. [`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/preact/reference/classes/QueryCache.md b/docs/framework/preact/reference/classes/QueryCache.md index b29348f1a4b..67d8c500d4a 100644 --- a/docs/framework/preact/reference/classes/QueryCache.md +++ b/docs/framework/preact/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/src/queryCache.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L122) The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information, and state of the queries it contains. @@ -34,7 +34,7 @@ const unsubscribe = queryCache.subscribe((event) => { 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -60,7 +60,7 @@ Subscribable.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) ## Methods @@ -73,7 +73,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -104,18 +104,28 @@ the reactive `QueryObserver` machinery. [`QueryClient`](QueryClient.md) +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -135,7 +145,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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -161,7 +171,7 @@ find(filters: WithRequired, `"queryKey"`\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -217,7 +232,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) findAll(filters?: QueryFilters): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) +Defined in: [packages/query-core/src/queryCache.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L330) 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. @@ -231,10 +246,14 @@ information about queries in rare scenarios. [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -257,7 +276,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -288,11 +307,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -310,7 +333,7 @@ const query = queryCache.get(queryHash) getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -318,6 +341,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -334,7 +359,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -342,6 +367,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -356,7 +383,7 @@ Subscribable.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -369,6 +396,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -392,7 +421,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -408,6 +437,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/preact/reference/classes/QueryClient.md b/docs/framework/preact/reference/classes/QueryClient.md index 07781860817..4dee1d4851c 100644 --- a/docs/framework/preact/reference/classes/QueryClient.md +++ b/docs/framework/preact/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/src/queryClient.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L78) `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 @@ -31,7 +31,7 @@ await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) 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/src/queryClient.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L88) #### Parameters @@ -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/src/queryClient.ts:459](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L459) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -72,14 +72,22 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### cancelOptions? [`CancelOptions`](../interfaces/CancelOptions.md) = `{}` +Passed to each matched query's cancellation. `revert` defaults to +`true`. + #### Returns `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -94,7 +102,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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -119,7 +127,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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -138,10 +146,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + *** ### defaultQueryOptions() @@ -152,7 +164,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -192,10 +204,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + *** ### ~~ensureInfiniteQueryData()~~ @@ -204,7 +221,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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -234,10 +251,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -250,7 +273,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/src/queryClient.ts:205](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L205) #### Type Parameters @@ -276,10 +299,16 @@ Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanS [`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options. If the query has no cached data yet, it is fetched with +these options. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached data, or to the fetched data if nothing was +cached yet. + #### Deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -292,7 +321,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/src/queryClient.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L746) #### Type Parameters @@ -322,10 +351,16 @@ Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached or fetched [InfiniteData](../interfaces/InfiniteData.md), or rejects with +the fetch error. + #### Deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. @@ -338,7 +373,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/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643) #### Type Parameters @@ -368,10 +403,16 @@ Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached or fetched data, or rejects with the fetch +error. + #### Deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. @@ -384,7 +425,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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -393,6 +434,8 @@ Returns the default options that were set when creating the client, or via [`DefaultOptions`](../interfaces/DefaultOptions.md) +The client's current default options. + #### Example ```ts @@ -410,7 +453,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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -418,6 +461,8 @@ Returns the mutation cache this client is connected to. [`MutationCache`](MutationCache.md) +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -436,7 +481,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/src/queryClient.ts:1015](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1015) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -448,10 +493,15 @@ defaults match, they are merged together in registration order. readonly `unknown`[] +The mutation key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -466,7 +516,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/src/queryClient.ts:251](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L251) 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 @@ -494,6 +544,8 @@ contents. `TQueryFilters` +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -518,7 +570,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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -526,6 +578,8 @@ Returns the query cache this client is connected to. [`QueryCache`](QueryCache.md) +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -544,7 +598,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/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) 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. @@ -572,6 +626,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + #### Returns `TInferredQueryFnData` \| `undefined` @@ -590,7 +646,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/src/queryClient.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L955) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -602,10 +658,15 @@ match, they are merged together in registration order. readonly `unknown`[] +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -622,7 +683,7 @@ getQueryState \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -675,7 +740,7 @@ console.log(state?.dataUpdatedAt) infiniteQuery(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/src/queryClient.ts:716](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L716) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -715,10 +780,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -738,7 +809,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/src/queryClient.ts:492](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L492) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -759,14 +830,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? [`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -781,7 +861,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/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) 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 @@ -799,10 +879,15 @@ loading more infinite query results. `TQueryFilters` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -819,7 +904,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/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -836,10 +921,15 @@ matching a set of filters. `TMutationFilters` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -856,7 +946,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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -875,7 +965,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/src/queryClient.ts:772](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L772) #### Type Parameters @@ -905,10 +995,15 @@ Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -921,7 +1016,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/src/queryClient.ts:680](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L680) #### Type Parameters @@ -947,10 +1042,15 @@ Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -963,7 +1063,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/src/queryClient.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L593) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1018,10 +1118,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -1040,7 +1146,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/src/queryClient.ts:533](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L533) 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 @@ -1062,14 +1168,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1085,7 +1199,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/src/queryClient.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L395) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1104,6 +1218,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1122,7 +1239,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/src/queryClient.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L420) 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 @@ -1140,14 +1257,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? [`ResetOptions`](../interfaces/ResetOptions.md) +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1162,7 +1287,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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1171,6 +1296,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1188,7 +1315,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/src/queryClient.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L903) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1199,6 +1326,8 @@ default options. [`DefaultOptions`](../interfaces/DefaultOptions.md) +The new default options for queries and mutations. + #### Returns `void` @@ -1228,7 +1357,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/src/queryClient.ts:985](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L985) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1258,10 +1387,14 @@ matters when several registered defaults match the same mutation key. readonly `unknown`[] +The mutation key that mutation keys are partially matched against. + ##### options [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +The default options applied to matching mutations. + #### Returns `void` @@ -1287,7 +1420,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/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L336) 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 @@ -1310,14 +1443,21 @@ filters are updated; no new cache entries are created. Internally this calls `TQueryFilters` +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? [`SetDataOptions`](../interfaces/SetDataOptions.md) +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -1344,7 +1484,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/src/queryClient.ts:283](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L283) 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; @@ -1413,7 +1553,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/src/queryClient.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L923) Sets default options for queries whose query key partially matches the given `queryKey`. @@ -1446,10 +1586,14 @@ after more generic ones so they take precedence. readonly `unknown`[] +The query key that query keys are partially matched against. + ##### options `Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -1470,7 +1614,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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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/preact/reference/classes/QueryObserver.md b/docs/framework/preact/reference/classes/QueryObserver.md index 845acfe60cb..78898c0b788 100644 --- a/docs/framework/preact/reference/classes/QueryObserver.md +++ b/docs/framework/preact/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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) 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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -93,7 +93,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -103,7 +103,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -121,7 +121,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -135,10 +135,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -157,7 +161,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -165,6 +169,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -173,7 +179,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -184,6 +190,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -199,7 +207,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -212,10 +220,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -224,7 +236,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -232,6 +244,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -243,24 +257,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -276,7 +295,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -290,6 +309,8 @@ refetch-interval timers as needed. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -320,6 +341,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -328,7 +351,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -338,6 +361,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -346,7 +371,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -362,6 +387,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -413,7 +440,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -450,6 +477,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -487,7 +516,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -500,6 +529,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -529,10 +560,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -541,7 +576,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/preact/reference/functions/dehydrate.md b/docs/framework/preact/reference/functions/dehydrate.md index 4999cadaf08..772a36e9366 100644 --- a/docs/framework/preact/reference/functions/dehydrate.md +++ b/docs/framework/preact/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/preact/reference/functions/experimental_streamedQuery.md b/docs/framework/preact/reference/functions/experimental_streamedQuery.md index 791a80817f2..35dd7c09176 100644 --- a/docs/framework/preact/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/preact/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(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -30,14 +30,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/preact/reference/functions/keepPreviousData.md b/docs/framework/preact/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/preact/reference/functions/keepPreviousData.md +++ b/docs/framework/preact/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/preact/reference/functions/shouldThrowError.md b/docs/framework/preact/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/preact/reference/functions/shouldThrowError.md +++ b/docs/framework/preact/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/preact/reference/interfaces/FocusManager.md b/docs/framework/preact/reference/interfaces/FocusManager.md index 3d59e85c451..95250b0999f 100644 --- a/docs/framework/preact/reference/interfaces/FocusManager.md +++ b/docs/framework/preact/reference/interfaces/FocusManager.md @@ -21,7 +21,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -29,6 +29,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -43,7 +45,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -51,6 +53,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -59,7 +63,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -75,7 +79,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -89,6 +93,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -120,7 +127,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -131,6 +138,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -158,7 +167,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -174,6 +183,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/preact/reference/interfaces/OnlineManager.md b/docs/framework/preact/reference/interfaces/OnlineManager.md index 7e97e7bc137..e3e17cd2a1b 100644 --- a/docs/framework/preact/reference/interfaces/OnlineManager.md +++ b/docs/framework/preact/reference/interfaces/OnlineManager.md @@ -25,7 +25,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -33,6 +33,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -47,7 +49,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -55,6 +57,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -63,7 +67,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -76,6 +80,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -101,7 +108,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -111,6 +118,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -135,7 +144,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -151,6 +160,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/preact/reference/interfaces/TimeoutManager.md b/docs/framework/preact/reference/interfaces/TimeoutManager.md index 164487133a6..06477f667a2 100644 --- a/docs/framework/preact/reference/interfaces/TimeoutManager.md +++ b/docs/framework/preact/reference/interfaces/TimeoutManager.md @@ -7,7 +7,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -27,7 +27,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -39,6 +39,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -70,7 +72,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -82,6 +84,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -113,7 +117,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -127,14 +131,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -160,7 +170,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -175,14 +185,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -238,6 +254,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/preact/reference/variables/notifyManager.md b/docs/framework/preact/reference/variables/notifyManager.md index abc590e3442..1358af7c7d4 100644 --- a/docs/framework/preact/reference/variables/notifyManager.md +++ b/docs/framework/preact/reference/variables/notifyManager.md @@ -7,7 +7,7 @@ title: notifyManager const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -36,10 +36,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -60,10 +64,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -99,6 +107,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -127,6 +137,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -146,6 +158,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` diff --git a/docs/framework/react/reference/classes/InfiniteQueryObserver.md b/docs/framework/react/reference/classes/InfiniteQueryObserver.md index 85e20576a06..bae39b3f6ed 100644 --- a/docs/framework/react/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/react/reference/classes/InfiniteQueryObserver.md @@ -6,7 +6,7 @@ redirect_from: - framework/react/reference/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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch between infinite queries. It augments the base `QueryObserverResult` with @@ -61,7 +61,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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -89,13 +89,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -117,7 +121,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -131,7 +135,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -147,6 +151,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -173,7 +179,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -195,7 +201,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -209,10 +215,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -235,7 +247,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -249,10 +261,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -275,7 +291,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -289,10 +305,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -315,7 +337,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -323,6 +345,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -335,7 +359,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -348,10 +372,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -364,7 +392,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -372,6 +400,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -381,24 +411,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -431,6 +466,8 @@ implementation. [`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -457,6 +494,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -469,7 +508,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -479,6 +518,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -516,7 +557,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -553,6 +594,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -594,7 +637,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -607,6 +650,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -636,10 +681,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -652,7 +701,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/react/reference/classes/MutationCache.md b/docs/framework/react/reference/classes/MutationCache.md index 9d1093fd570..415f845d3e5 100644 --- a/docs/framework/react/reference/classes/MutationCache.md +++ b/docs/framework/react/reference/classes/MutationCache.md @@ -6,7 +6,7 @@ redirect_from: - framework/react/reference/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/src/mutationCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L123) The `MutationCache` is the storage for mutations. @@ -34,7 +34,7 @@ const unsubscribe = mutationCache.subscribe((event) => { 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -60,7 +60,7 @@ Subscribable.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) ## Methods @@ -70,7 +70,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -96,7 +96,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/src/mutationCache.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L300) 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. @@ -128,11 +128,15 @@ information about a mutation in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -153,7 +157,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] }) 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/src/mutationCache.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L331) 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. @@ -167,10 +171,14 @@ information about mutations in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -191,7 +199,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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -202,6 +210,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -218,7 +228,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -226,6 +236,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -240,7 +252,7 @@ Subscribable.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -256,6 +268,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/react/reference/classes/MutationObserver.md b/docs/framework/react/reference/classes/MutationObserver.md index 87c7814735b..13ec27342ff 100644 --- a/docs/framework/react/reference/classes/MutationObserver.md +++ b/docs/framework/react/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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/react/reference/classes/QueriesObserver.md b/docs/framework/react/reference/classes/QueriesObserver.md index d1da9a32fda..fd23c2d83d3 100644 --- a/docs/framework/react/reference/classes/QueriesObserver.md +++ b/docs/framework/react/reference/classes/QueriesObserver.md @@ -6,7 +6,7 @@ redirect_from: - framework/react/reference/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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) A `QueriesObserver` watches an array of queries at once, exposing them as a single array of `QueryObserverResult`s (or, when a `combine` option is @@ -48,7 +48,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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -82,7 +82,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -99,7 +99,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -109,6 +109,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -124,7 +126,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -134,6 +136,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -142,7 +146,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -156,14 +160,21 @@ wrap the results for property-access tracking. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -172,7 +183,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -181,6 +192,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -189,7 +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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -197,6 +210,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -211,7 +226,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -224,10 +239,14 @@ observers are created and subscribed to for newly added queries. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -249,7 +268,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -265,6 +284,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/react/reference/classes/Query.md b/docs/framework/react/reference/classes/Query.md index c6b5f29ac9c..4bef73a69e0 100644 --- a/docs/framework/react/reference/classes/Query.md +++ b/docs/framework/react/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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. [`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/react/reference/classes/QueryCache.md b/docs/framework/react/reference/classes/QueryCache.md index 283e6569d3c..59ff5aad0ec 100644 --- a/docs/framework/react/reference/classes/QueryCache.md +++ b/docs/framework/react/reference/classes/QueryCache.md @@ -6,7 +6,7 @@ redirect_from: - framework/react/reference/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/src/queryCache.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L122) The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information, and state of the queries it contains. @@ -37,7 +37,7 @@ const unsubscribe = queryCache.subscribe((event) => { 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -63,7 +63,7 @@ Subscribable.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) ## Methods @@ -76,7 +76,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -107,18 +107,28 @@ the reactive `QueryObserver` machinery. [`QueryClient`](QueryClient.md) +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -138,7 +148,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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -164,7 +174,7 @@ find(filters: WithRequired, `"queryKey"`\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -220,7 +235,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) findAll(filters?: QueryFilters): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) +Defined in: [packages/query-core/src/queryCache.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L330) 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. @@ -234,10 +249,14 @@ information about queries in rare scenarios. [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -260,7 +279,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -291,11 +310,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -313,7 +336,7 @@ const query = queryCache.get(queryHash) getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -321,6 +344,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -337,7 +362,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -345,6 +370,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -359,7 +386,7 @@ Subscribable.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -372,6 +399,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -395,7 +424,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -411,6 +440,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/react/reference/classes/QueryClient.md b/docs/framework/react/reference/classes/QueryClient.md index bdeedc74486..0a9f7192c7a 100644 --- a/docs/framework/react/reference/classes/QueryClient.md +++ b/docs/framework/react/reference/classes/QueryClient.md @@ -6,7 +6,7 @@ redirect_from: - framework/react/reference/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/src/queryClient.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L78) `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 @@ -34,7 +34,7 @@ await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) 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/src/queryClient.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L88) #### Parameters @@ -54,7 +54,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/src/queryClient.ts:459](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L459) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -75,14 +75,22 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### cancelOptions? [`CancelOptions`](../interfaces/CancelOptions.md) = `{}` +Passed to each matched query's cancellation. `revert` defaults to +`true`. + #### Returns `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -97,7 +105,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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -122,7 +130,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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -141,10 +149,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + *** ### defaultQueryOptions() @@ -155,7 +167,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -195,10 +207,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + *** ### ~~ensureInfiniteQueryData()~~ @@ -207,7 +224,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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -237,10 +254,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -253,7 +276,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/src/queryClient.ts:205](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L205) #### Type Parameters @@ -279,10 +302,16 @@ Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanS [`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options. If the query has no cached data yet, it is fetched with +these options. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached data, or to the fetched data if nothing was +cached yet. + #### Deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -295,7 +324,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/src/queryClient.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L746) #### Type Parameters @@ -325,10 +354,16 @@ Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached or fetched [InfiniteData](../interfaces/InfiniteData.md), or rejects with +the fetch error. + #### Deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. @@ -341,7 +376,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/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643) #### Type Parameters @@ -371,10 +406,16 @@ Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached or fetched data, or rejects with the fetch +error. + #### Deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. @@ -387,7 +428,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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -396,6 +437,8 @@ Returns the default options that were set when creating the client, or via [`DefaultOptions`](../interfaces/DefaultOptions.md) +The client's current default options. + #### Example ```ts @@ -413,7 +456,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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -421,6 +464,8 @@ Returns the mutation cache this client is connected to. [`MutationCache`](MutationCache.md) +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -439,7 +484,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/src/queryClient.ts:1015](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1015) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -451,10 +496,15 @@ defaults match, they are merged together in registration order. readonly `unknown`[] +The mutation key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -469,7 +519,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/src/queryClient.ts:251](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L251) 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 @@ -497,6 +547,8 @@ contents. `TQueryFilters` +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -521,7 +573,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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -529,6 +581,8 @@ Returns the query cache this client is connected to. [`QueryCache`](QueryCache.md) +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -547,7 +601,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/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) 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. @@ -575,6 +629,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + #### Returns `TInferredQueryFnData` \| `undefined` @@ -593,7 +649,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/src/queryClient.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L955) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -605,10 +661,15 @@ match, they are merged together in registration order. readonly `unknown`[] +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -625,7 +686,7 @@ getQueryState \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -678,7 +743,7 @@ console.log(state?.dataUpdatedAt) infiniteQuery(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/src/queryClient.ts:716](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L716) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -718,10 +783,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -741,7 +812,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/src/queryClient.ts:492](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L492) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -762,14 +833,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? [`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -784,7 +864,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/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) 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 @@ -802,10 +882,15 @@ loading more infinite query results. `TQueryFilters` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -822,7 +907,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/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -839,10 +924,15 @@ matching a set of filters. `TMutationFilters` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -859,7 +949,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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -878,7 +968,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/src/queryClient.ts:772](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L772) #### Type Parameters @@ -908,10 +998,15 @@ Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -924,7 +1019,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/src/queryClient.ts:680](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L680) #### Type Parameters @@ -950,10 +1045,15 @@ Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -966,7 +1066,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/src/queryClient.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L593) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1021,10 +1121,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -1043,7 +1149,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/src/queryClient.ts:533](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L533) 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 @@ -1065,14 +1171,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1088,7 +1202,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/src/queryClient.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L395) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1107,6 +1221,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1125,7 +1242,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/src/queryClient.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L420) 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 @@ -1143,14 +1260,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? [`ResetOptions`](../interfaces/ResetOptions.md) +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1165,7 +1290,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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1174,6 +1299,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1191,7 +1318,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/src/queryClient.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L903) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1202,6 +1329,8 @@ default options. [`DefaultOptions`](../interfaces/DefaultOptions.md) +The new default options for queries and mutations. + #### Returns `void` @@ -1231,7 +1360,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/src/queryClient.ts:985](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L985) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1261,10 +1390,14 @@ matters when several registered defaults match the same mutation key. readonly `unknown`[] +The mutation key that mutation keys are partially matched against. + ##### options [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +The default options applied to matching mutations. + #### Returns `void` @@ -1290,7 +1423,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/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L336) 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 @@ -1313,14 +1446,21 @@ filters are updated; no new cache entries are created. Internally this calls `TQueryFilters` +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? [`SetDataOptions`](../interfaces/SetDataOptions.md) +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -1347,7 +1487,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/src/queryClient.ts:283](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L283) 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; @@ -1416,7 +1556,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/src/queryClient.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L923) Sets default options for queries whose query key partially matches the given `queryKey`. @@ -1449,10 +1589,14 @@ after more generic ones so they take precedence. readonly `unknown`[] +The query key that query keys are partially matched against. + ##### options `Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -1473,7 +1617,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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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/react/reference/classes/QueryObserver.md b/docs/framework/react/reference/classes/QueryObserver.md index a01a48e5e4e..3b86838d9a0 100644 --- a/docs/framework/react/reference/classes/QueryObserver.md +++ b/docs/framework/react/reference/classes/QueryObserver.md @@ -6,7 +6,7 @@ redirect_from: - framework/react/reference/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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) A `QueryObserver` watches a single query in the `QueryCache` and computes a `QueryObserverResult` from its state, recomputing and notifying subscribers @@ -66,7 +66,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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -96,7 +96,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -106,7 +106,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -124,7 +124,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -138,10 +138,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -160,7 +164,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -168,6 +172,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -176,7 +182,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -187,6 +193,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -202,7 +210,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -215,10 +223,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -227,7 +239,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -235,6 +247,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -246,24 +260,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -279,7 +298,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -293,6 +312,8 @@ refetch-interval timers as needed. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -323,6 +344,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -331,7 +354,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -341,6 +364,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -349,7 +374,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -365,6 +390,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -416,7 +443,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -453,6 +480,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -490,7 +519,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -503,6 +532,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -532,10 +563,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -544,7 +579,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/react/reference/functions/dehydrate.md b/docs/framework/react/reference/functions/dehydrate.md index 4999cadaf08..772a36e9366 100644 --- a/docs/framework/react/reference/functions/dehydrate.md +++ b/docs/framework/react/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/react/reference/functions/experimental_streamedQuery.md b/docs/framework/react/reference/functions/experimental_streamedQuery.md index cdab63c6e62..0747ffbe044 100644 --- a/docs/framework/react/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/react/reference/functions/experimental_streamedQuery.md @@ -6,10 +6,10 @@ redirect_from: --- ```ts -function experimental_streamedQuery(streamFn: StreamedQueryParams): (context: object) => TData | Promise; +function experimental_streamedQuery(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -32,14 +32,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/react/reference/functions/keepPreviousData.md b/docs/framework/react/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/react/reference/functions/keepPreviousData.md +++ b/docs/framework/react/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/react/reference/functions/shouldThrowError.md b/docs/framework/react/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/react/reference/functions/shouldThrowError.md +++ b/docs/framework/react/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/react/reference/interfaces/FocusManager.md b/docs/framework/react/reference/interfaces/FocusManager.md index 2eb409d804b..5429d07b13c 100644 --- a/docs/framework/react/reference/interfaces/FocusManager.md +++ b/docs/framework/react/reference/interfaces/FocusManager.md @@ -24,7 +24,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -32,6 +32,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -46,7 +48,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -54,6 +56,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -62,7 +66,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -78,7 +82,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -92,6 +96,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -123,7 +130,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -134,6 +141,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -161,7 +170,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -177,6 +186,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/react/reference/interfaces/OnlineManager.md b/docs/framework/react/reference/interfaces/OnlineManager.md index 65abb535361..84ab902902e 100644 --- a/docs/framework/react/reference/interfaces/OnlineManager.md +++ b/docs/framework/react/reference/interfaces/OnlineManager.md @@ -28,7 +28,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -36,6 +36,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -50,7 +52,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -58,6 +60,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -66,7 +70,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -79,6 +83,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -104,7 +111,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -114,6 +121,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -138,7 +147,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -154,6 +163,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/react/reference/interfaces/TimeoutManager.md b/docs/framework/react/reference/interfaces/TimeoutManager.md index b6971209e15..e28ceba74d2 100644 --- a/docs/framework/react/reference/interfaces/TimeoutManager.md +++ b/docs/framework/react/reference/interfaces/TimeoutManager.md @@ -9,7 +9,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -29,7 +29,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -41,6 +41,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -72,7 +74,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -84,6 +86,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -115,7 +119,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -129,14 +133,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -162,7 +172,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -177,14 +187,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -240,6 +256,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/react/reference/variables/notifyManager.md b/docs/framework/react/reference/variables/notifyManager.md index 98c410ba027..a98aa142413 100644 --- a/docs/framework/react/reference/variables/notifyManager.md +++ b/docs/framework/react/reference/variables/notifyManager.md @@ -10,7 +10,7 @@ redirect_from: const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -39,10 +39,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -63,10 +67,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -102,6 +110,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -130,6 +140,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -149,6 +161,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` diff --git a/docs/framework/solid/reference/classes/InfiniteQueryObserver.md b/docs/framework/solid/reference/classes/InfiniteQueryObserver.md index e5c47cfae87..fba7cec9902 100644 --- a/docs/framework/solid/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/solid/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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) 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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -86,13 +86,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -114,7 +118,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -128,7 +132,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -144,6 +148,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -170,7 +176,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -192,7 +198,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -206,10 +212,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -232,7 +244,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -246,10 +258,14 @@ navigated to) will need, ahead of time. `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -272,7 +288,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -286,10 +302,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -312,7 +334,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -320,6 +342,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -332,7 +356,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -345,10 +369,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -361,7 +389,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -369,6 +397,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -378,24 +408,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -428,6 +463,8 @@ implementation. `InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -454,6 +491,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -466,7 +505,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -476,6 +515,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -513,7 +554,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -550,6 +591,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -591,7 +634,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -604,6 +647,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -633,10 +678,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -649,7 +698,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/solid/reference/classes/MutationCache.md b/docs/framework/solid/reference/classes/MutationCache.md index 4b8f85cab33..9e7e7ed406c 100644 --- a/docs/framework/solid/reference/classes/MutationCache.md +++ b/docs/framework/solid/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/src/mutationCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L123) The `MutationCache` is the storage for mutations. @@ -31,7 +31,7 @@ const unsubscribe = mutationCache.subscribe((event) => { 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -57,7 +57,7 @@ Subscribable.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) ## Methods @@ -67,7 +67,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -93,7 +93,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/src/mutationCache.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L300) 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. @@ -125,11 +125,15 @@ information about a mutation in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -150,7 +154,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] }) 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/src/mutationCache.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L331) 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. @@ -164,10 +168,14 @@ information about mutations in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -188,7 +196,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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -199,6 +207,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -215,7 +225,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -223,6 +233,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -237,7 +249,7 @@ Subscribable.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -253,6 +265,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/solid/reference/classes/MutationObserver.md b/docs/framework/solid/reference/classes/MutationObserver.md index cdb0fbe8ac1..5977d3f2e32 100644 --- a/docs/framework/solid/reference/classes/MutationObserver.md +++ b/docs/framework/solid/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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/solid/reference/classes/QueriesObserver.md b/docs/framework/solid/reference/classes/QueriesObserver.md index 3a07c7a44d8..3fee0a2724e 100644 --- a/docs/framework/solid/reference/classes/QueriesObserver.md +++ b/docs/framework/solid/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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) 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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -79,7 +79,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -96,7 +96,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -106,6 +106,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -121,7 +123,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -131,6 +133,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -139,7 +143,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -153,14 +157,21 @@ wrap the results for property-access tracking. `QueryObserverOptions`\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -169,7 +180,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -178,6 +189,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -186,7 +199,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -194,6 +207,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -208,7 +223,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -221,10 +236,14 @@ observers are created and subscribed to for newly added queries. `QueryObserverOptions`\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -246,7 +265,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -262,6 +281,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/solid/reference/classes/Query.md b/docs/framework/solid/reference/classes/Query.md index 30b20ec99a2..f7ed703fae7 100644 --- a/docs/framework/solid/reference/classes/Query.md +++ b/docs/framework/solid/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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. `QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/solid/reference/classes/QueryCache.md b/docs/framework/solid/reference/classes/QueryCache.md index 20f8773d189..cde9c6b5272 100644 --- a/docs/framework/solid/reference/classes/QueryCache.md +++ b/docs/framework/solid/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/src/queryCache.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L122) The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information, and state of the queries it contains. @@ -34,7 +34,7 @@ const unsubscribe = queryCache.subscribe((event) => { 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -60,7 +60,7 @@ Subscribable.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) ## Methods @@ -73,7 +73,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -104,18 +104,28 @@ the reactive `QueryObserver` machinery. `QueryClient` +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -135,7 +145,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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -161,7 +171,7 @@ find(filters: WithRequired, `"queryKey"`\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -217,7 +232,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) findAll(filters?: QueryFilters): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) +Defined in: [packages/query-core/src/queryCache.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L330) 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. @@ -231,10 +246,14 @@ information about queries in rare scenarios. [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -257,7 +276,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -288,11 +307,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -310,7 +333,7 @@ const query = queryCache.get(queryHash) getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -318,6 +341,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -334,7 +359,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -342,6 +367,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -356,7 +383,7 @@ Subscribable.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -369,6 +396,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -392,7 +421,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -408,6 +437,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/solid/reference/classes/QueryClient.md b/docs/framework/solid/reference/classes/QueryClient.md index 5e62f97ea61..b228f4a50dd 100644 --- a/docs/framework/solid/reference/classes/QueryClient.md +++ b/docs/framework/solid/reference/classes/QueryClient.md @@ -3,7 +3,7 @@ id: QueryClient title: QueryClient --- -Defined in: [packages/solid-query/src/QueryClient.ts:109](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L109) +Defined in: [packages/solid-query/src/QueryClient.ts:106](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L106) The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.queries` accepts Solid's `reconcile` option. @@ -20,7 +20,7 @@ The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.quer new QueryClient(config?: QueryClientConfig): QueryClient; ``` -Defined in: [packages/solid-query/src/QueryClient.ts:110](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L110) +Defined in: [packages/solid-query/src/QueryClient.ts:107](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L107) #### Parameters @@ -46,7 +46,7 @@ QueryCoreClient.constructor 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/src/queryClient.ts:459](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L459) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -67,14 +67,22 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### cancelOptions? [`CancelOptions`](../interfaces/CancelOptions.md) = `{}` +Passed to each matched query's cancellation. `revert` defaults to +`true`. + #### Returns `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -95,7 +103,7 @@ QueryCoreClient.cancelQueries 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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -126,7 +134,7 @@ QueryCoreClient.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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -145,10 +153,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + #### Inherited from ```ts @@ -165,7 +177,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -205,10 +217,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + #### Inherited from ```ts @@ -223,7 +240,7 @@ QueryCoreClient.defaultQueryOptions 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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -253,10 +270,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -275,7 +298,7 @@ QueryCoreClient.ensureInfiniteQueryData 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/src/queryClient.ts:205](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L205) #### Type Parameters @@ -301,10 +324,16 @@ Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanS [`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options. If the query has no cached data yet, it is fetched with +these options. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached data, or to the fetched data if nothing was +cached yet. + #### Deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -323,7 +352,7 @@ QueryCoreClient.ensureQueryData 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/src/queryClient.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L746) #### Type Parameters @@ -353,10 +382,16 @@ Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached or fetched [InfiniteData](../interfaces/InfiniteData.md), or rejects with +the fetch error. + #### Deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. @@ -375,7 +410,7 @@ QueryCoreClient.fetchInfiniteQuery 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/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643) #### Type Parameters @@ -405,10 +440,16 @@ Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached or fetched data, or rejects with the fetch +error. + #### Deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. @@ -427,7 +468,7 @@ QueryCoreClient.fetchQuery 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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -436,6 +477,8 @@ Returns the default options that were set when creating the client, or via `DefaultOptions` +The client's current default options. + #### Example ```ts @@ -459,7 +502,7 @@ QueryCoreClient.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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -467,6 +510,8 @@ Returns the mutation cache this client is connected to. [`MutationCache`](MutationCache.md) +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -491,7 +536,7 @@ QueryCoreClient.getMutationCache 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/src/queryClient.ts:1015](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1015) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -503,10 +548,15 @@ defaults match, they are merged together in registration order. readonly `unknown`[] +The mutation key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -527,7 +577,7 @@ QueryCoreClient.getMutationDefaults 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/src/queryClient.ts:251](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L251) 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 @@ -555,6 +605,8 @@ contents. `TQueryFilters` +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -585,7 +637,7 @@ QueryCoreClient.getQueriesData 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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -593,6 +645,8 @@ Returns the query cache this client is connected to. [`QueryCache`](QueryCache.md) +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -617,7 +671,7 @@ QueryCoreClient.getQueryCache 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/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) 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. @@ -645,6 +699,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + #### Returns `TInferredQueryFnData` \| `undefined` @@ -669,7 +725,7 @@ QueryCoreClient.getQueryData 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/src/queryClient.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L955) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -681,10 +737,15 @@ match, they are merged together in registration order. readonly `unknown`[] +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<`QueryObserverOptions`\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -707,7 +768,7 @@ getQueryState \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -766,7 +831,7 @@ QueryCoreClient.getQueryState infiniteQuery(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/src/queryClient.ts:716](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L716) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -806,10 +871,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -835,7 +906,7 @@ QueryCoreClient.infiniteQuery 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/src/queryClient.ts:492](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L492) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -856,14 +927,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? [`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -884,7 +964,7 @@ QueryCoreClient.invalidateQueries 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/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) 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 @@ -902,10 +982,15 @@ loading more infinite query results. `TQueryFilters` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -928,7 +1013,7 @@ QueryCoreClient.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/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -945,10 +1030,15 @@ matching a set of filters. `TMutationFilters` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -971,7 +1061,7 @@ QueryCoreClient.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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -996,7 +1086,7 @@ QueryCoreClient.mount 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/src/queryClient.ts:772](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L772) #### Type Parameters @@ -1026,10 +1116,15 @@ Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -1048,7 +1143,7 @@ QueryCoreClient.prefetchInfiniteQuery 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/src/queryClient.ts:680](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L680) #### Type Parameters @@ -1074,10 +1169,15 @@ Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -1096,7 +1196,7 @@ QueryCoreClient.prefetchQuery 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/src/queryClient.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L593) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1151,10 +1251,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -1179,7 +1285,7 @@ QueryCoreClient.query 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/src/queryClient.ts:533](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L533) 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 @@ -1201,14 +1307,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1230,7 +1344,7 @@ QueryCoreClient.refetchQueries 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/src/queryClient.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L395) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1249,6 +1363,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1273,7 +1390,7 @@ QueryCoreClient.removeQueries 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/src/queryClient.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L420) 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 @@ -1291,14 +1408,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? [`ResetOptions`](../interfaces/ResetOptions.md) +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1319,7 +1444,7 @@ QueryCoreClient.resetQueries 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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1328,6 +1453,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1351,7 +1478,7 @@ QueryCoreClient.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/src/queryClient.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L903) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1362,6 +1489,8 @@ default options. `DefaultOptions` +The new default options for queries and mutations. + #### Returns `void` @@ -1397,7 +1526,7 @@ QueryCoreClient.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/src/queryClient.ts:985](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L985) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1427,10 +1556,14 @@ matters when several registered defaults match the same mutation key. readonly `unknown`[] +The mutation key that mutation keys are partially matched against. + ##### options [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +The default options applied to matching mutations. + #### Returns `void` @@ -1462,7 +1595,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/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L336) 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 @@ -1485,14 +1618,21 @@ filters are updated; no new cache entries are created. Internally this calls `TQueryFilters` +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? [`SetDataOptions`](../interfaces/SetDataOptions.md) +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -1525,7 +1665,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/src/queryClient.ts:283](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L283) 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; @@ -1600,7 +1740,7 @@ QueryCoreClient.setQueryData 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/src/queryClient.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L923) Sets default options for queries whose query key partially matches the given `queryKey`. @@ -1633,10 +1773,14 @@ after more generic ones so they take precedence. readonly `unknown`[] +The query key that query keys are partially matched against. + ##### options `Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -1663,7 +1807,7 @@ QueryCoreClient.setQueryDefaults 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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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/solid/reference/classes/QueryObserver.md b/docs/framework/solid/reference/classes/QueryObserver.md index e1cf5882f45..7387cd0853e 100644 --- a/docs/framework/solid/reference/classes/QueryObserver.md +++ b/docs/framework/solid/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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) 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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -93,7 +93,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -103,7 +103,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -121,7 +121,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -135,10 +135,14 @@ navigated to) will need, ahead of time. `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -157,7 +161,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -165,6 +169,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -173,7 +179,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -184,6 +190,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -199,7 +207,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -212,10 +220,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -224,7 +236,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -232,6 +244,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -243,24 +257,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -276,7 +295,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -290,6 +309,8 @@ refetch-interval timers as needed. `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -320,6 +341,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -328,7 +351,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -338,6 +361,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -346,7 +371,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -362,6 +387,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -413,7 +440,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -450,6 +477,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -487,7 +516,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -500,6 +529,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -529,10 +560,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -541,7 +576,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/solid/reference/functions/dehydrate.md b/docs/framework/solid/reference/functions/dehydrate.md index 78d9ea88531..9fe267b0603 100644 --- a/docs/framework/solid/reference/functions/dehydrate.md +++ b/docs/framework/solid/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul `QueryClient` +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/solid/reference/functions/experimental_streamedQuery.md b/docs/framework/solid/reference/functions/experimental_streamedQuery.md index 791a80817f2..35dd7c09176 100644 --- a/docs/framework/solid/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/solid/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(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -30,14 +30,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/solid/reference/functions/keepPreviousData.md b/docs/framework/solid/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/solid/reference/functions/keepPreviousData.md +++ b/docs/framework/solid/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/solid/reference/functions/shouldThrowError.md b/docs/framework/solid/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/solid/reference/functions/shouldThrowError.md +++ b/docs/framework/solid/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/solid/reference/interfaces/FocusManager.md b/docs/framework/solid/reference/interfaces/FocusManager.md index 3d59e85c451..95250b0999f 100644 --- a/docs/framework/solid/reference/interfaces/FocusManager.md +++ b/docs/framework/solid/reference/interfaces/FocusManager.md @@ -21,7 +21,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -29,6 +29,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -43,7 +45,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -51,6 +53,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -59,7 +63,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -75,7 +79,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -89,6 +93,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -120,7 +127,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -131,6 +138,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -158,7 +167,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -174,6 +183,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/solid/reference/interfaces/OnlineManager.md b/docs/framework/solid/reference/interfaces/OnlineManager.md index 7e97e7bc137..e3e17cd2a1b 100644 --- a/docs/framework/solid/reference/interfaces/OnlineManager.md +++ b/docs/framework/solid/reference/interfaces/OnlineManager.md @@ -25,7 +25,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -33,6 +33,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -47,7 +49,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -55,6 +57,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -63,7 +67,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -76,6 +80,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -101,7 +108,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -111,6 +118,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -135,7 +144,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -151,6 +160,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/solid/reference/interfaces/TimeoutManager.md b/docs/framework/solid/reference/interfaces/TimeoutManager.md index 164487133a6..06477f667a2 100644 --- a/docs/framework/solid/reference/interfaces/TimeoutManager.md +++ b/docs/framework/solid/reference/interfaces/TimeoutManager.md @@ -7,7 +7,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -27,7 +27,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -39,6 +39,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -70,7 +72,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -82,6 +84,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -113,7 +117,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -127,14 +131,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -160,7 +170,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -175,14 +185,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -238,6 +254,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/solid/reference/variables/notifyManager.md b/docs/framework/solid/reference/variables/notifyManager.md index abc590e3442..1358af7c7d4 100644 --- a/docs/framework/solid/reference/variables/notifyManager.md +++ b/docs/framework/solid/reference/variables/notifyManager.md @@ -7,7 +7,7 @@ title: notifyManager const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -36,10 +36,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -60,10 +64,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -99,6 +107,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -127,6 +137,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -146,6 +158,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` diff --git a/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md b/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md index 1a70c8ebf7f..710bf14ae5c 100644 --- a/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/svelte/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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) 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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -86,13 +86,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -114,7 +118,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -128,7 +132,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -144,6 +148,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -170,7 +176,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -192,7 +198,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -206,10 +212,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -232,7 +244,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -246,10 +258,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -272,7 +288,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -286,10 +302,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -312,7 +334,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -320,6 +342,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -332,7 +356,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -345,10 +369,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -361,7 +389,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -369,6 +397,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -378,24 +408,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -428,6 +463,8 @@ implementation. [`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -454,6 +491,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -466,7 +505,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -476,6 +515,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -513,7 +554,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -550,6 +591,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -591,7 +634,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -604,6 +647,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -633,10 +678,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -649,7 +698,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/svelte/reference/classes/MutationCache.md b/docs/framework/svelte/reference/classes/MutationCache.md index 4b8f85cab33..9e7e7ed406c 100644 --- a/docs/framework/svelte/reference/classes/MutationCache.md +++ b/docs/framework/svelte/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/src/mutationCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L123) The `MutationCache` is the storage for mutations. @@ -31,7 +31,7 @@ const unsubscribe = mutationCache.subscribe((event) => { 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -57,7 +57,7 @@ Subscribable.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) ## Methods @@ -67,7 +67,7 @@ Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/Ta 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -93,7 +93,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/src/mutationCache.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L300) 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. @@ -125,11 +125,15 @@ information about a mutation in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -150,7 +154,7 @@ const mutation = mutationCache.find({ mutationKey: ['addPost'] }) 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/src/mutationCache.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L331) 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. @@ -164,10 +168,14 @@ information about mutations in rare scenarios. [`MutationFilters`](../interfaces/MutationFilters.md) = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -188,7 +196,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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -199,6 +207,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -215,7 +225,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -223,6 +233,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -237,7 +249,7 @@ Subscribable.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -253,6 +265,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/MutationObserver.md b/docs/framework/svelte/reference/classes/MutationObserver.md index 87c7814735b..13ec27342ff 100644 --- a/docs/framework/svelte/reference/classes/MutationObserver.md +++ b/docs/framework/svelte/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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/QueriesObserver.md b/docs/framework/svelte/reference/classes/QueriesObserver.md index 08c997c2d13..a05cddbc172 100644 --- a/docs/framework/svelte/reference/classes/QueriesObserver.md +++ b/docs/framework/svelte/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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) 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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -79,7 +79,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -96,7 +96,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -106,6 +106,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -121,7 +123,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -131,6 +133,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -139,7 +143,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -153,14 +157,21 @@ wrap the results for property-access tracking. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -169,7 +180,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -178,6 +189,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -186,7 +199,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -194,6 +207,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -208,7 +223,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -221,10 +236,14 @@ observers are created and subscribed to for newly added queries. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -246,7 +265,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -262,6 +281,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/Query.md b/docs/framework/svelte/reference/classes/Query.md index c6b5f29ac9c..4bef73a69e0 100644 --- a/docs/framework/svelte/reference/classes/Query.md +++ b/docs/framework/svelte/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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. [`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/svelte/reference/classes/QueryCache.md b/docs/framework/svelte/reference/classes/QueryCache.md index b29348f1a4b..67d8c500d4a 100644 --- a/docs/framework/svelte/reference/classes/QueryCache.md +++ b/docs/framework/svelte/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/src/queryCache.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L122) The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information, and state of the queries it contains. @@ -34,7 +34,7 @@ const unsubscribe = queryCache.subscribe((event) => { 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -60,7 +60,7 @@ Subscribable.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) ## Methods @@ -73,7 +73,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -104,18 +104,28 @@ the reactive `QueryObserver` machinery. [`QueryClient`](QueryClient.md) +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -135,7 +145,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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -161,7 +171,7 @@ find(filters: WithRequired, `"queryKey"`\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -217,7 +232,7 @@ const query = queryCache.find({ queryKey: ['posts'] }) findAll(filters?: QueryFilters): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L319) +Defined in: [packages/query-core/src/queryCache.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L330) 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. @@ -231,10 +246,14 @@ information about queries in rare scenarios. [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -257,7 +276,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -288,11 +307,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -310,7 +333,7 @@ const query = queryCache.get(queryHash) getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -318,6 +341,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -334,7 +359,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -342,6 +367,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -356,7 +383,7 @@ Subscribable.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -369,6 +396,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -392,7 +421,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -408,6 +437,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/svelte/reference/classes/QueryClient.md b/docs/framework/svelte/reference/classes/QueryClient.md index 07781860817..4dee1d4851c 100644 --- a/docs/framework/svelte/reference/classes/QueryClient.md +++ b/docs/framework/svelte/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/src/queryClient.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L78) `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 @@ -31,7 +31,7 @@ await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) 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/src/queryClient.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L88) #### Parameters @@ -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/src/queryClient.ts:459](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L459) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -72,14 +72,22 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### cancelOptions? [`CancelOptions`](../interfaces/CancelOptions.md) = `{}` +Passed to each matched query's cancellation. `revert` defaults to +`true`. + #### Returns `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -94,7 +102,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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -119,7 +127,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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -138,10 +146,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + *** ### defaultQueryOptions() @@ -152,7 +164,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -192,10 +204,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + *** ### ~~ensureInfiniteQueryData()~~ @@ -204,7 +221,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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -234,10 +251,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -250,7 +273,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/src/queryClient.ts:205](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L205) #### Type Parameters @@ -276,10 +299,16 @@ Defined in: [packages/query-core/src/queryClient.ts:198](https://github.com/TanS [`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options. If the query has no cached data yet, it is fetched with +these options. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached data, or to the fetched data if nothing was +cached yet. + #### Deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -292,7 +321,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/src/queryClient.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L746) #### Type Parameters @@ -322,10 +351,16 @@ Defined in: [packages/query-core/src/queryClient.ts:702](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached or fetched [InfiniteData](../interfaces/InfiniteData.md), or rejects with +the fetch error. + #### Deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. @@ -338,7 +373,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/src/queryClient.ts:643](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L643) #### Type Parameters @@ -368,10 +403,16 @@ Defined in: [packages/query-core/src/queryClient.ts:609](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the cached or fetched data, or rejects with the fetch +error. + #### Deprecated Use queryClient.query(options) instead. This method will be removed in the next major version. @@ -384,7 +425,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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -393,6 +434,8 @@ Returns the default options that were set when creating the client, or via [`DefaultOptions`](../interfaces/DefaultOptions.md) +The client's current default options. + #### Example ```ts @@ -410,7 +453,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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -418,6 +461,8 @@ Returns the mutation cache this client is connected to. [`MutationCache`](MutationCache.md) +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -436,7 +481,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/src/queryClient.ts:1015](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1015) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -448,10 +493,15 @@ defaults match, they are merged together in registration order. readonly `unknown`[] +The mutation key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -466,7 +516,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/src/queryClient.ts:251](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L251) 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 @@ -494,6 +544,8 @@ contents. `TQueryFilters` +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -518,7 +570,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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -526,6 +578,8 @@ Returns the query cache this client is connected to. [`QueryCache`](QueryCache.md) +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -544,7 +598,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/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) 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. @@ -572,6 +626,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + #### Returns `TInferredQueryFnData` \| `undefined` @@ -590,7 +646,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/src/queryClient.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L955) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -602,10 +658,15 @@ match, they are merged together in registration order. readonly `unknown`[] +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -622,7 +683,7 @@ getQueryState \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -675,7 +740,7 @@ console.log(state?.dataUpdatedAt) infiniteQuery(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/src/queryClient.ts:716](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L716) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -715,10 +780,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -738,7 +809,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/src/queryClient.ts:492](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L492) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -759,14 +830,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? [`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -781,7 +861,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/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) 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 @@ -799,10 +879,15 @@ loading more infinite query results. `TQueryFilters` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -819,7 +904,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/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -836,10 +921,15 @@ matching a set of filters. `TMutationFilters` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -856,7 +946,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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -875,7 +965,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/src/queryClient.ts:772](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L772) #### Type Parameters @@ -905,10 +995,15 @@ Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanS [`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -921,7 +1016,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/src/queryClient.ts:680](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L680) #### Type Parameters @@ -947,10 +1042,15 @@ Defined in: [packages/query-core/src/queryClient.ts:643](https://github.com/TanS [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`void`\> +A promise that resolves once the fetch settles. It never rejects. + #### Deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. @@ -963,7 +1063,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/src/queryClient.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L593) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1018,10 +1118,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + #### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + #### Example ```ts @@ -1040,7 +1146,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/src/queryClient.ts:533](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L533) 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 @@ -1062,14 +1168,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1085,7 +1199,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/src/queryClient.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L395) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1104,6 +1218,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1122,7 +1239,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/src/queryClient.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L420) 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 @@ -1140,14 +1257,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? [`ResetOptions`](../interfaces/ResetOptions.md) +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1162,7 +1287,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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1171,6 +1296,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1188,7 +1315,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/src/queryClient.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L903) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1199,6 +1326,8 @@ default options. [`DefaultOptions`](../interfaces/DefaultOptions.md) +The new default options for queries and mutations. + #### Returns `void` @@ -1228,7 +1357,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/src/queryClient.ts:985](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L985) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1258,10 +1387,14 @@ matters when several registered defaults match the same mutation key. readonly `unknown`[] +The mutation key that mutation keys are partially matched against. + ##### options [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +The default options applied to matching mutations. + #### Returns `void` @@ -1287,7 +1420,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/src/queryClient.ts:336](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L336) 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 @@ -1310,14 +1443,21 @@ filters are updated; no new cache entries are created. Internally this calls `TQueryFilters` +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? [`SetDataOptions`](../interfaces/SetDataOptions.md) +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] @@ -1344,7 +1484,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/src/queryClient.ts:283](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L283) 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; @@ -1413,7 +1553,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/src/queryClient.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L923) Sets default options for queries whose query key partially matches the given `queryKey`. @@ -1446,10 +1586,14 @@ after more generic ones so they take precedence. readonly `unknown`[] +The query key that query keys are partially matched against. + ##### options `Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -1470,7 +1614,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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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/svelte/reference/classes/QueryObserver.md b/docs/framework/svelte/reference/classes/QueryObserver.md index 845acfe60cb..78898c0b788 100644 --- a/docs/framework/svelte/reference/classes/QueryObserver.md +++ b/docs/framework/svelte/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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) 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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -93,7 +93,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -103,7 +103,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -121,7 +121,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -135,10 +135,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -157,7 +161,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -165,6 +169,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -173,7 +179,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -184,6 +190,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -199,7 +207,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -212,10 +220,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -224,7 +236,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -232,6 +244,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -243,24 +257,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -276,7 +295,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -290,6 +309,8 @@ refetch-interval timers as needed. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -320,6 +341,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -328,7 +351,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -338,6 +361,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -346,7 +371,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -362,6 +387,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -413,7 +440,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -450,6 +477,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -487,7 +516,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -500,6 +529,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -529,10 +560,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -541,7 +576,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/svelte/reference/functions/dehydrate.md b/docs/framework/svelte/reference/functions/dehydrate.md index 4999cadaf08..772a36e9366 100644 --- a/docs/framework/svelte/reference/functions/dehydrate.md +++ b/docs/framework/svelte/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul [`QueryClient`](../classes/QueryClient.md) +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/svelte/reference/functions/experimental_streamedQuery.md b/docs/framework/svelte/reference/functions/experimental_streamedQuery.md index 791a80817f2..35dd7c09176 100644 --- a/docs/framework/svelte/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/svelte/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(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -30,14 +30,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/svelte/reference/functions/keepPreviousData.md b/docs/framework/svelte/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/svelte/reference/functions/keepPreviousData.md +++ b/docs/framework/svelte/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/svelte/reference/functions/shouldThrowError.md b/docs/framework/svelte/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/svelte/reference/functions/shouldThrowError.md +++ b/docs/framework/svelte/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/svelte/reference/interfaces/FocusManager.md b/docs/framework/svelte/reference/interfaces/FocusManager.md index 3d59e85c451..95250b0999f 100644 --- a/docs/framework/svelte/reference/interfaces/FocusManager.md +++ b/docs/framework/svelte/reference/interfaces/FocusManager.md @@ -21,7 +21,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -29,6 +29,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -43,7 +45,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -51,6 +53,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -59,7 +63,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -75,7 +79,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -89,6 +93,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -120,7 +127,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -131,6 +138,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -158,7 +167,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -174,6 +183,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/svelte/reference/interfaces/OnlineManager.md b/docs/framework/svelte/reference/interfaces/OnlineManager.md index 7e97e7bc137..e3e17cd2a1b 100644 --- a/docs/framework/svelte/reference/interfaces/OnlineManager.md +++ b/docs/framework/svelte/reference/interfaces/OnlineManager.md @@ -25,7 +25,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -33,6 +33,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -47,7 +49,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -55,6 +57,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -63,7 +67,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -76,6 +80,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -101,7 +108,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -111,6 +118,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -135,7 +144,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -151,6 +160,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/svelte/reference/interfaces/TimeoutManager.md b/docs/framework/svelte/reference/interfaces/TimeoutManager.md index 164487133a6..06477f667a2 100644 --- a/docs/framework/svelte/reference/interfaces/TimeoutManager.md +++ b/docs/framework/svelte/reference/interfaces/TimeoutManager.md @@ -7,7 +7,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -27,7 +27,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -39,6 +39,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -70,7 +72,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -82,6 +84,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -113,7 +117,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -127,14 +131,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -160,7 +170,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -175,14 +185,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -238,6 +254,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/svelte/reference/variables/notifyManager.md b/docs/framework/svelte/reference/variables/notifyManager.md index abc590e3442..1358af7c7d4 100644 --- a/docs/framework/svelte/reference/variables/notifyManager.md +++ b/docs/framework/svelte/reference/variables/notifyManager.md @@ -7,7 +7,7 @@ title: notifyManager const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -36,10 +36,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -60,10 +64,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -99,6 +107,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -127,6 +137,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -146,6 +158,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` diff --git a/docs/framework/vue/reference/classes/InfiniteQueryObserver.md b/docs/framework/vue/reference/classes/InfiniteQueryObserver.md index cd891813557..308451413bf 100644 --- a/docs/framework/vue/reference/classes/InfiniteQueryObserver.md +++ b/docs/framework/vue/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/src/infiniteQueryObserver.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L40) 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/src/infiniteQueryObserver.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L82) #### Parameters @@ -86,13 +86,17 @@ Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github 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/src/infiniteQueryObserver.ts:59](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L59) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates as they happen, subscribe to the observer instead (its inherited `subscribe` method). +#### Returns + +The current result. + #### Example ```ts @@ -114,7 +118,7 @@ QueryObserver.getCurrentResult 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) #### Inherited from @@ -128,7 +132,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/src/infiniteQueryObserver.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L54) 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 @@ -144,6 +148,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -170,7 +176,7 @@ QueryObserver.subscribe 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -192,7 +198,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/src/infiniteQueryObserver.ts:165](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L165) Fetches the next page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -206,10 +212,16 @@ receives the current pages/page params and whose result also determines [`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the next page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the next page may not be fetched. + #### Example ```ts @@ -232,7 +244,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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -246,10 +258,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -272,7 +288,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/src/infiniteQueryObserver.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L196) Fetches the previous page of the infinite query and returns a promise that resolves with the resulting `InfiniteQueryObserverResult`. The page @@ -286,10 +302,16 @@ receives the current pages/page params and whose result also determines [`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) +Set `cancelRefetch` to `false` to ignore the call while a fetch is running, +and `throwOnError` to `true` to reject when the fetch fails. + #### Returns `Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the previous page is fetched. With +`cancelRefetch: false`, a running fetch is reused instead, so the previous page may not be fetched. + #### Example ```ts @@ -312,7 +334,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -320,6 +342,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> +The observed query. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) @@ -332,7 +356,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/src/infiniteQueryObserver.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L129) 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. @@ -345,10 +369,14 @@ synchronously. [`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The defaulted infinite query observer options to compute the result for. + #### Returns [`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + #### Overrides [`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) @@ -361,7 +389,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -369,6 +397,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) @@ -378,24 +408,29 @@ Returns `true` while at least one listener is registered, `false` once they have ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -428,6 +463,8 @@ implementation. [`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The new infinite query observer options. + #### Returns `void` @@ -454,6 +491,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) @@ -466,7 +505,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -476,6 +515,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) @@ -513,7 +554,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -550,6 +591,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -591,7 +634,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) 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 @@ -604,6 +647,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -633,10 +678,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + #### Inherited from [`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) @@ -649,7 +698,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/vue/reference/classes/MutationCache.md b/docs/framework/vue/reference/classes/MutationCache.md index 9465fefe61f..f2668f159fa 100644 --- a/docs/framework/vue/reference/classes/MutationCache.md +++ b/docs/framework/vue/reference/classes/MutationCache.md @@ -21,7 +21,7 @@ MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Parameters @@ -47,7 +47,7 @@ MC.constructor 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/src/mutationCache.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L128) #### Inherited from @@ -63,7 +63,7 @@ MC.config 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/src/mutationCache.ts:257](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L257) Removes all mutations from the cache. @@ -127,11 +127,15 @@ information about a mutation in rare scenarios. `MaybeRefDeep`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> +The filters to match. `exact` defaults to `true`. + #### Returns \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +The first matching mutation, or `undefined`. + #### See [MutationCache#findAll](#findall) @@ -172,10 +176,14 @@ information about mutations in rare scenarios. `MaybeRefDeep`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` +The filters to match. Without filters, every mutation is returned. + #### Returns [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +The matching mutations. + #### See [MutationCache#find](#find) @@ -202,7 +210,7 @@ MC.findAll 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/src/mutationCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L280) Returns all mutations within the cache. @@ -213,6 +221,8 @@ information about a mutation in rare scenarios. [`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] +Every mutation in the cache. + #### Example ```ts @@ -235,7 +245,7 @@ MC.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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -243,6 +253,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -257,7 +269,7 @@ MC.hasListeners 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -273,6 +285,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/vue/reference/classes/MutationObserver.md b/docs/framework/vue/reference/classes/MutationObserver.md index cdb0fbe8ac1..5977d3f2e32 100644 --- a/docs/framework/vue/reference/classes/MutationObserver.md +++ b/docs/framework/vue/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/src/mutationObserver.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L37) 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/src/mutationObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L57) #### Parameters @@ -82,7 +82,7 @@ Subscribable< 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/src/mutationObserver.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L45) ## Methods @@ -92,7 +92,7 @@ Defined in: [packages/query-core/src/mutationObserver.ts:46](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/src/mutationObserver.ts:160](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L160) Returns the observer's current result, derived from the observed mutation's state (or the default, `idle` state if no mutation has been @@ -102,6 +102,8 @@ built yet, e.g. before the first `mutate()` call or after `reset()`). [`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The current result. + *** ### hasListeners() @@ -110,7 +112,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -118,6 +120,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -132,7 +136,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/src/mutationObserver.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L212) Builds a new `Mutation` in the `MutationCache` using the observer's current options, detaches this observer from any previously observed @@ -149,14 +153,20 @@ on the observer's own options. `TVariables` +The variables passed to the `mutationFn`. + ##### options? [`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +Per-call `onSuccess`, `onError`, and `onSettled` callbacks. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the mutation's data, or rejects with its error. + #### Example ```ts @@ -174,7 +184,7 @@ await observer.mutate( 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/src/mutationObserver.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L183) Detaches the observer from the mutation it is currently observing (if any) and resets the observed result back to its default, `idle` state. @@ -221,6 +231,8 @@ observing. Otherwise, if the currently observed mutation is still [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +The new mutation observer options. They are defaulted with [QueryClient#defaultMutationOptions](QueryClient.md#defaultmutationoptions) before being applied. + #### Returns `void` @@ -242,7 +254,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -258,6 +270,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/vue/reference/classes/QueriesObserver.md b/docs/framework/vue/reference/classes/QueriesObserver.md index 82eae3afdfa..79364128192 100644 --- a/docs/framework/vue/reference/classes/QueriesObserver.md +++ b/docs/framework/vue/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/src/queriesObserver.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L61) 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/src/queriesObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L75) #### Parameters @@ -79,7 +79,7 @@ Subscribable.constructor 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/src/queriesObserver.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L111) Stops observing all queries: clears all listeners and destroys every underlying `QueryObserver` this observer manages. @@ -96,7 +96,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/src/queriesObserver.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L216) Returns the most recently computed array of `QueryObserverResult`s, one per observed query, in the same order as the queries passed to the @@ -106,6 +106,8 @@ constructor or `setQueries`. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] +The current results. + #### Example ```ts @@ -121,7 +123,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/src/queriesObserver.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L235) Returns the underlying `QueryObserver` instances this observer manages, in the same order as the queries passed to the constructor or @@ -131,6 +133,8 @@ in the same order as the queries passed to the constructor or [`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] +The managed query observers. + *** ### getOptimisticResult() @@ -139,7 +143,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/src/queriesObserver.ts:250](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L250) The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes the result for the given (already-defaulted) queries right now, synchronously. Called by @@ -153,14 +157,21 @@ wrap the results for property-access tracking. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The defaulted options of the queries to compute the result for. + ##### combine `CombineFn`\<`TCombinedResult`\> \| `undefined` +The `combine` function used by the returned `combineResult`, if any. + #### Returns \[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`: [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] +A tuple of the per-query results, a function that computes the combined result, and a +function that returns the results wrapped for property-access tracking. + *** ### getQueries() @@ -169,7 +180,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/src/queriesObserver.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L225) Returns the underlying `Query` instances currently being observed, in the same order as the queries passed to the constructor or `setQueries`. @@ -178,6 +189,8 @@ the same order as the queries passed to the constructor or `setQueries`. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The observed queries. + *** ### hasListeners() @@ -186,7 +199,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -194,6 +207,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -208,7 +223,7 @@ Subscribable.hasListeners 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/src/queriesObserver.ts:133](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L133) Replaces the set of queries being observed. Existing `QueryObserver`s are reused for queries that match an already-observed query hash; @@ -221,10 +236,14 @@ observers are created and subscribed to for newly added queries. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] +The options of the queries to observe. + ##### options? [`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> +Replaces the observer's options, e.g. its `combine` function. + #### Returns `void` @@ -246,7 +265,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -262,6 +281,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/vue/reference/classes/Query.md b/docs/framework/vue/reference/classes/Query.md index 30b20ec99a2..f7ed703fae7 100644 --- a/docs/framework/vue/reference/classes/Query.md +++ b/docs/framework/vue/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/src/query.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L224) 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/src/query.ts:245](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L245) #### Parameters @@ -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/src/query.ts:241](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L241) *** @@ -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/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) *** @@ -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/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) *** @@ -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/src/query.ts:230](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L230) *** @@ -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/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) ## Accessors @@ -156,6 +156,8 @@ The `meta` object passed in the query's options, if any. `Record`\<`string`, `unknown`\> \| `undefined` +The query's `meta`, or `undefined` if none was set. + *** ### promise @@ -166,7 +168,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/src/query.ts:281](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L281) The promise for the currently in-flight fetch, if the query is fetching. `undefined` when the query is not fetching. @@ -175,6 +177,8 @@ The promise for the currently in-flight fetch, if the query is fetching. `Promise`\<`TData`\> \| `undefined` +The promise of the in-flight fetch, or `undefined`. + ## Methods ### cancel() @@ -183,7 +187,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/src/query.ts:364](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L364) Cancels the query's currently in-flight fetch, if any. - Returns a promise that resolves once the cancellation has settled. @@ -195,10 +199,15 @@ Cancels the query's currently in-flight fetch, if any. [`CancelOptions`](../interfaces/CancelOptions.md) +Set `revert` to restore the state from before the fetch started, and `silent` +to suppress the cancellation error when a new fetch replaces the cancelled one. + #### Returns `Promise`\<`void`\> +A promise that resolves once the cancellation has settled. + #### Example ```ts @@ -213,7 +222,7 @@ await query.cancel() 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/src/query.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L376) Clears the query's garbage collection timeout and silently cancels any in-flight fetch. Called by `QueryCache` when the query is removed from @@ -241,7 +250,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/src/query.ts:629](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L629) Fetches the query, i.e. runs its `queryFn` (through any configured retryer/behavior) and updates the query's state with the result. @@ -258,14 +267,24 @@ retryer/behavior) and updates the query's state with the result. `QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> +Query options that replace the query's current options before fetching. They +are not applied when an in-flight fetch is reused. + ##### fetchOptions? `FetchOptions`\<`TQueryFnData`\> +Set `cancelRefetch` to cancel an in-flight fetch first (only if the query +already has data), and `meta` to pass extra information to the query's behavior. + #### Returns `Promise`\<`TData`\> +A promise that resolves with the fetched data, or rejects with the fetch error. If the +fetch is cancelled with `revert` while the query has data, it resolves with the restored data +instead. + *** ### getObserversCount() @@ -274,7 +293,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/src/query.ts:593](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L593) Returns the number of observers currently subscribed to this query. @@ -282,6 +301,8 @@ Returns the number of observers currently subscribed to this query. `number` +The number of observers. + #### Example ```ts @@ -298,7 +319,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/src/query.ts:606](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L606) Marks the query as invalidated, unless it is already invalidated. This updates `state.isInvalidated` and notifies observers, but does not by @@ -322,7 +343,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/src/query.ts:405](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L405) Returns `true` if the query has at least one observer for which `enabled` does not resolve to `false`. @@ -331,6 +352,8 @@ does not resolve to `false`. `boolean` +`true` if the query has an enabled observer. + *** ### isDisabled() @@ -339,7 +362,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/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) Returns `true` if the query is disabled, meaning it will not fetch automatically. @@ -352,6 +375,8 @@ automatically. `boolean` +`true` if the query is disabled. + *** ### isFetched() @@ -360,7 +385,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/src/query.ts:433](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L433) Returns `true` if the query has been fetched, i.e. it has resolved with either data or an error at least once. @@ -369,6 +394,8 @@ either data or an error at least once. `boolean` +`true` if the query has been fetched. + *** ### isStale() @@ -377,7 +404,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/src/query.ts:469](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L469) Returns `true` if the query is stale. - If the query has observers, defers to whether any observer's current @@ -390,6 +417,8 @@ Returns `true` if the query is stale. `boolean` +`true` if the query is stale. + #### See [Query#isStaleByTime](#isstalebytime) @@ -410,7 +439,7 @@ if (query.isStale()) { isStaleByTime(staleTime?: number | "static"): 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/src/query.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L497) Returns `true` if the query's data is stale relative to the given `staleTime` (defaults to `0`). @@ -425,10 +454,15 @@ Returns `true` if the query's data is stale relative to the given `number` \| `"static"` +The time, in milliseconds, after which data is considered stale, or +`'static'` to never treat existing data as stale. A query without data is stale either way. + #### Returns `boolean` +`true` if the query's data is stale. + #### See [Query#isStale](#isstale) @@ -447,7 +481,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/src/query.ts:442](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L442) Returns `true` if the query has at least one observer configured with `staleTime: 'static'`, meaning it is treated as never stale. @@ -456,6 +490,8 @@ Returns `true` if the query has at least one observer configured with `boolean` +`true` if the query is static. + *** ### reset() @@ -464,7 +500,7 @@ Returns `true` if the query has at least one observer configured with 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/src/query.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L395) 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 @@ -482,7 +518,7 @@ in-flight fetch. 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/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) 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 @@ -494,6 +530,8 @@ user manually trigger a loading/error state or edit the cached data. `Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> +The partial state to merge into the query's state. + #### Returns `void` diff --git a/docs/framework/vue/reference/classes/QueryCache.md b/docs/framework/vue/reference/classes/QueryCache.md index 57cea9626f9..d6ac2ef8221 100644 --- a/docs/framework/vue/reference/classes/QueryCache.md +++ b/docs/framework/vue/reference/classes/QueryCache.md @@ -21,7 +21,7 @@ MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Parameters @@ -47,7 +47,7 @@ QC.constructor 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/src/queryCache.ts:125](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L125) #### Inherited from @@ -66,7 +66,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/src/queryCache.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L151) 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 @@ -97,18 +97,28 @@ the reactive `QueryObserver` machinery. `QueryClient` +The client the query belongs to, used to default its options. + ##### options [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> +The query options, including the `queryKey`. A new query is created with the +options defaulted by [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions). + ##### state? [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> +The initial state of a newly created query, e.g. when hydrating. Ignored if the +query already exists. + #### Returns [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +The existing or newly created query. + #### Example ```ts @@ -134,7 +144,7 @@ QC.build 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/src/queryCache.ts:235](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L235) Removes all queries from the cache. @@ -197,11 +207,16 @@ decide whether a query is fresh enough to be used as an initial value). `MaybeRefDeep`\<[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\>\> +The filters to match, including the required `queryKey`. `exact` defaults to +`true`. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +The first matching query, or `undefined`. + #### See [QueryCache#findAll](#findall) @@ -242,10 +257,14 @@ information about queries in rare scenarios. `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` +The filters to match. Without filters, every query is returned. + #### Returns [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +The matching queries. + #### See [QueryCache#find](#find) @@ -274,7 +293,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/src/queryCache.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L258) 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 @@ -305,11 +324,15 @@ to look up directly. `string` +The hash of the query to look up. + #### Returns \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> \| `undefined` +The query stored under the hash, or `undefined`. + #### Example ```ts @@ -333,7 +356,7 @@ QC.get getAll(): Query[]; ``` -Defined in: [packages/query-core/src/queryCache.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L272) +Defined in: [packages/query-core/src/queryCache.ts:280](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L280) Returns all queries within the cache. @@ -341,6 +364,8 @@ Returns all queries within the cache. [`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +Every query in the cache. + #### Example ```ts @@ -363,7 +388,7 @@ QC.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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -371,6 +396,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -385,7 +412,7 @@ QC.hasListeners 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/src/queryCache.ts:216](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L216) 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 @@ -398,6 +425,8 @@ removals across `QueryCache` instances. [`Query`](Query.md)\<`any`, `any`, `any`, `any`\> +The query to remove. + #### Returns `void` @@ -427,7 +456,7 @@ QC.remove 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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -443,6 +472,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/vue/reference/classes/QueryClient.md b/docs/framework/vue/reference/classes/QueryClient.md index be2d36f1aa5..f830751611f 100644 --- a/docs/framework/vue/reference/classes/QueryClient.md +++ b/docs/framework/vue/reference/classes/QueryClient.md @@ -90,6 +90,9 @@ The returned promise never rejects, even if individual cancellations fail. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to cancel. Without filters, every query +is cancelled. + ##### options? `MaybeRefDeep`\<[`CancelOptions`](../interfaces/CancelOptions.md)\> @@ -98,6 +101,8 @@ The returned promise never rejects, even if individual cancellations fail. `Promise`\<`void`\> +A promise that resolves once every cancellation has settled. + #### Example ```ts @@ -118,7 +123,7 @@ QC.cancelQueries 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/src/queryClient.ts:1157](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1157) Clears both the query cache and the mutation cache this client is connected to. @@ -149,7 +154,7 @@ QC.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/src/queryClient.ts:1132](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1132) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the @@ -168,10 +173,14 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). `T` +The mutation options passed by the caller. + #### Returns `T` +The defaulted options. + #### Inherited from ```ts @@ -188,7 +197,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/src/queryClient.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1043) 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 @@ -228,10 +237,15 @@ on top. A no-op if the options are already defaulted (`_defaulted: true`). \| [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> \| [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The query options passed by the caller. + #### Returns [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted options, with `queryHash` and dependent defaults (e.g. +`refetchOnReconnect`) filled in. + #### Inherited from ```ts @@ -246,7 +260,7 @@ QC.defaultQueryOptions 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/src/queryClient.ts:798](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L798) #### Type Parameters @@ -276,10 +290,16 @@ Defined in: [packages/query-core/src/queryClient.ts:747](https://github.com/TanS [`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options. If the query has no cached data yet, it is fetched +with these options. + #### Returns `Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> +A promise that resolves to the cached [InfiniteData](../interfaces/InfiniteData.md), or to the fetched data if +nothing was cached yet. + #### Deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. @@ -605,7 +625,7 @@ QC.fetchQuery 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/src/queryClient.ts:882](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L882) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -614,6 +634,8 @@ Returns the default options that were set when creating the client, or via [`DefaultOptions`](../interfaces/DefaultOptions.md) +The client's current default options. + #### Example ```ts @@ -637,7 +659,7 @@ QC.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/src/queryClient.ts:866](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L866) Returns the mutation cache this client is connected to. @@ -645,6 +667,8 @@ Returns the mutation cache this client is connected to. `MutationCache` +The [MutationCache](MutationCache.md) instance. + #### Example ```ts @@ -681,10 +705,15 @@ defaults match, they are merged together in registration order. `MaybeRefDeep`\ +The mutation key to look up registered defaults for. + #### Returns [`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -729,6 +758,8 @@ contents. `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> +The filters that select which queries to read. + #### Returns \[readonly `unknown`[], `TData` \| `undefined`\][] @@ -759,7 +790,7 @@ QC.getQueriesData 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/src/queryClient.ts:850](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L850) Returns the query cache this client is connected to. @@ -767,6 +798,8 @@ Returns the query cache this client is connected to. `QueryCache` +The [QueryCache](QueryCache.md) instance. + #### Example ```ts @@ -819,6 +852,8 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. `TTaggedQueryKey` +The query key of the query to read. + ##### Returns \| [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TData`, `TTaggedQueryKey`\> @@ -886,10 +921,15 @@ match, they are merged together in registration order. `MaybeRefDeep`\ +The query key to look up registered defaults for. + #### Returns [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +The merged default options of every registration that matches, or an empty object if +none match. + #### Example ```ts @@ -933,11 +973,15 @@ exist, `undefined` is returned. `MaybeRefDeep`\ +The query key of the query to read. + #### Returns \| [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> \| `undefined` +The query's state, or `undefined` if no query with this key exists. + #### Example ```ts @@ -1001,10 +1045,16 @@ This method replaces the deprecated `fetchInfiniteQuery`, and — combined with [`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +The infinite query options, including the `queryKey`, the `queryFn`, and the +`initialPageParam`. + ##### Returns `Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> +A promise that resolves to the [InfiniteData](../interfaces/InfiniteData.md), or to the result of `select` if +provided. It rejects with the error from the fetch or from `select`. + ##### Example ```ts @@ -1100,14 +1150,23 @@ Unless `filters.refetchType` is `'none'`, matching queries are then refetched vi \| [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> \| (() => [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\>) +The filters that select which queries to invalidate, plus `refetchType` to +control which of them to refetch afterwards. Without filters, every query is invalidated. + ##### options? `MaybeRefDeep`\<[`InvalidateOptions`](../interfaces/InvalidateOptions.md)\> +Passed to [QueryClient#refetchQueries](#refetchqueries), e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch settles, or immediately if `refetchType` is +`'none'`. + #### Example ```ts @@ -1140,10 +1199,15 @@ loading more infinite query results. `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` +Narrows down which fetching queries are counted. Without filters, every +fetching query is counted. + #### Returns `number` +The number of matching queries whose `fetchStatus` is `'fetching'`. + #### Example ```ts @@ -1177,10 +1241,15 @@ matching a set of filters. `MaybeRefDeep`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` +Narrows down which pending mutations are counted. Without filters, every +pending mutation is counted. + #### Returns `number` +The number of matching mutations whose `status` is `'pending'`. + #### Example ```ts @@ -1203,7 +1272,7 @@ QC.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/src/queryClient.ts:103](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L103) 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 @@ -1485,10 +1554,16 @@ This method replaces the deprecated `fetchQuery`, and — combined with [`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +The query options, including the `queryKey` and the `queryFn` used if the +query needs to fetch. + ##### Returns `Promise`\<`TData`\> +A promise that resolves to the data, or to the result of `select` if provided. It +rejects with the error from the fetch or from `select`. + ##### Example ```ts @@ -1585,14 +1660,22 @@ not reject on individual query failures unless `throwOnError` is set. [`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to refetch. Without filters, every query +in the cache is included. + ##### options? `MaybeRefDeep`\<[`RefetchOptions`](../interfaces/RefetchOptions.md)\> +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when a refetch fails. + #### Returns `Promise`\<`void`\> +A promise that resolves once every matched query has settled. + #### Example ```ts @@ -1633,6 +1716,9 @@ the cache is removed. [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to remove. Without filters, every query +is removed. + #### Returns `void` @@ -1675,14 +1761,22 @@ matched set are then refetched, and the returned promise resolves once that refe [`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> +The filters that select which queries to reset. Without filters, every query +is reset. + ##### options? `MaybeRefDeep`\<[`ResetOptions`](../interfaces/ResetOptions.md)\> +Passed to the refetch of the active matched queries, e.g. `cancelRefetch` and +`throwOnError`. + #### Returns `Promise`\<`void`\> +A promise that resolves once the refetch of the active matched queries settles. + #### Example ```ts @@ -1703,7 +1797,7 @@ QC.resetQueries 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/src/queryClient.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L831) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1712,6 +1806,8 @@ Resumes mutations that were paused because there was no network connection. Does `Promise`\<`unknown`\> +A promise that resolves once the resumed mutations have settled. + #### Example ```ts @@ -1746,6 +1842,8 @@ default options. `MaybeRefDeep`\<[`DefaultOptions`](../interfaces/DefaultOptions.md)\<`Error`\>\> +The new default options for queries and mutations. + #### Returns `void` @@ -1811,10 +1909,14 @@ matters when several registered defaults match the same mutation key. `MaybeRefDeep`\ +The mutation key that mutation keys are partially matched against. + ##### options `MaybeRefDeep`\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +The default options applied to matching mutations. + #### Returns `void` @@ -1865,14 +1967,21 @@ filters are updated; no new cache entries are created. Internally this calls `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> +The filters that select which existing queries to update. + ##### updater [`Updater`](../type-aliases/Updater.md)\<`TData` \| `undefined`, `TData` \| `undefined`\> +Either the new data, or a function that receives each matched query's current +data (which may be `undefined`) and returns the new data. + ##### options? `MaybeRefDeep`\<[`SetDataOptions`](../interfaces/SetDataOptions.md)\> = `{}` +Set `updatedAt` to override the timestamp the written data is recorded with. + #### Returns \[readonly `unknown`[], `TData` \| `undefined`\][] @@ -2060,10 +2169,14 @@ after more generic ones so they take precedence. `MaybeRefDeep`\ +The query key that query keys are partially matched against. + ##### options `MaybeRefDeep`\<`Omit`\<[`UseQueryOptions`](../type-aliases/UseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> +The default options applied to matching queries. + #### Returns `void` @@ -2090,7 +2203,7 @@ QC.setQueryDefaults 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/src/queryClient.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L126) 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/vue/reference/classes/QueryObserver.md b/docs/framework/vue/reference/classes/QueryObserver.md index 0ac42909a4b..7b3eb40d054 100644 --- a/docs/framework/vue/reference/classes/QueryObserver.md +++ b/docs/framework/vue/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/src/queryObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L56) 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/src/queryObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L86) #### Parameters @@ -93,7 +93,7 @@ Subscribable>.constructor 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/src/queryObserver.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L88) ## Methods @@ -103,7 +103,7 @@ Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/Tan 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/src/queryObserver.ts:162](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L162) Stops observing the current query: clears all listeners, cancels the stale and refetch-interval timers, and removes this observer from the @@ -121,7 +121,7 @@ query it was observing. 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/src/queryObserver.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L407) Fetches a query defined by the given options without affecting this observer's own tracked query or result, and returns a promise that @@ -135,10 +135,14 @@ navigated to) will need, ahead of time. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The observer options of the query to fetch. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result for the fetched query. + #### Example ```ts @@ -157,7 +161,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/src/queryObserver.ts:366](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L366) Returns the `Query` instance this observer is currently observing. @@ -165,6 +169,8 @@ Returns the `Query` instance this observer is currently observing. [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> +The observed query. + *** ### getCurrentResult() @@ -173,7 +179,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/src/queryObserver.ts:325](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L325) Returns the most recently computed `QueryObserverResult` for the observed query. This is a point-in-time read; to be notified of updates @@ -184,6 +190,8 @@ as they happen, subscribe to the observer instead (its inherited [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The current result. + #### Example ```ts @@ -199,7 +207,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/src/queryObserver.ts:276](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L276) 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 @@ -212,10 +220,14 @@ returned value is available synchronously, ahead of `setOptions` triggering an a [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The defaulted observer options to compute the result for. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result for the given options. + *** ### hasListeners() @@ -224,7 +236,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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -232,6 +244,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -243,24 +257,29 @@ Subscribable.hasListeners ### refetch() ```ts -refetch(__namedParameters?: RefetchOptions): Promise>; +refetch(options?: 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/src/queryObserver.ts:382](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L382) Refetches the observed query and returns a promise that resolves with the resulting `QueryObserverResult`. #### Parameters -##### \_\_namedParameters? +##### options? [`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` +Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling +it, and `throwOnError` to `true` to reject when the refetch fails. + #### Returns `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> +A promise that resolves with the result after the refetch. + #### Example ```ts @@ -276,7 +295,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/src/queryObserver.ts:184](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L184) Updates the observer's options. This will re-resolve the query being observed (switching to a different query if the `queryKey` changed), @@ -290,6 +309,8 @@ refetch-interval timers as needed. [`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +The new observer options. They are defaulted with [QueryClient#defaultQueryOptions](QueryClient.md#defaultqueryoptions) before being applied. + #### Returns `void` @@ -320,6 +341,8 @@ reconnects. `boolean` +`true` if the observer should refetch the query on reconnect. + *** ### shouldFetchOnWindowFocus() @@ -328,7 +351,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/src/queryObserver.ts:149](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L149) Returns whether the observed query is currently stale and configured (via the `refetchOnWindowFocus` option) to refetch when the window @@ -338,6 +361,8 @@ regains focus. `boolean` +`true` if the observer should refetch the query on window focus. + *** ### subscribe() @@ -346,7 +371,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) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -362,6 +387,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example @@ -413,7 +440,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/src/queryObserver.ts:358](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L358) 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 @@ -450,6 +477,8 @@ access themselves (e.g. through their own reactivity system) instead of via the \| `"refetch"` \| `"fetchStatus"` +The name of the property that was read. + #### Returns `void` @@ -487,7 +516,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/src/queryObserver.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L338) Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via [QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework @@ -500,6 +529,8 @@ properties you actually read" behavior. [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +The result to wrap. + ##### onPropTracked? (`key`: @@ -529,10 +560,14 @@ properties you actually read" behavior. \| `"refetch"` \| `"fetchStatus"`) => `void` +Called with the name of each property that is read. + #### Returns [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> +A proxy of `result` that tracks property reads. + *** ### updateResult() @@ -541,7 +576,7 @@ properties you actually read" behavior. updateResult(): void; ``` -Defined in: [packages/query-core/src/queryObserver.ts:733](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L733) +Defined in: [packages/query-core/src/queryObserver.ts:745](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L745) 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/vue/reference/functions/dehydrate.md b/docs/framework/vue/reference/functions/dehydrate.md index 78d9ea88531..9fe267b0603 100644 --- a/docs/framework/vue/reference/functions/dehydrate.md +++ b/docs/framework/vue/reference/functions/dehydrate.md @@ -7,7 +7,7 @@ title: dehydrate 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/src/hydration.ts:239](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L239) 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,14 +21,21 @@ falling back to the client's `dehydrate` default options, and finally to `defaul `QueryClient` +The client whose cache is dehydrated. + ### options? [`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` +Controls which queries and mutations are included and how their data and errors +are transformed. Each option falls back to the client's `defaultOptions.dehydrate`. + ## Returns [`DehydratedState`](../interfaces/DehydratedState.md) +The dehydrated state, with the included `queries` and `mutations`. + ## Example ```ts diff --git a/docs/framework/vue/reference/functions/experimental_streamedQuery.md b/docs/framework/vue/reference/functions/experimental_streamedQuery.md index 791a80817f2..35dd7c09176 100644 --- a/docs/framework/vue/reference/functions/experimental_streamedQuery.md +++ b/docs/framework/vue/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(options: StreamedQueryParams): (context: object) => TData | Promise; ``` -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/src/streamedQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L70) 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. @@ -30,14 +30,17 @@ The query will stay in fetchStatus 'fetching' until the stream ends. ## Parameters -### streamFn +### options `StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> -The function that returns an AsyncIterable to stream data from. +The `streamFn` that returns an AsyncIterable to stream data from, and the optional +`refetchMode`, `reducer`, and `initialValue` options. ## Returns +A query function to pass as `queryFn`. + (`context`: `object`) => `TData` \| `Promise`\<`TData`\> ## Example diff --git a/docs/framework/vue/reference/functions/keepPreviousData.md b/docs/framework/vue/reference/functions/keepPreviousData.md index 5f2d328a5b8..6bfdcd2d81a 100644 --- a/docs/framework/vue/reference/functions/keepPreviousData.md +++ b/docs/framework/vue/reference/functions/keepPreviousData.md @@ -7,7 +7,7 @@ title: keepPreviousData function keepPreviousData(previousData: T | undefined): T | undefined; ``` -Defined in: [packages/query-core/src/utils.ts:499](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L499) +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) Intended to be passed as a query's `placeholderData` option, for example `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new @@ -25,10 +25,14 @@ query key is fetching, it keeps displaying the previously fetched data until the `T` \| `undefined` +The data of the previous query key, passed by the observer. + ## Returns `T` \| `undefined` +The previous data, unchanged. + ## Example ```ts diff --git a/docs/framework/vue/reference/functions/shouldThrowError.md b/docs/framework/vue/reference/functions/shouldThrowError.md index 7d26951a636..267f6d412fb 100644 --- a/docs/framework/vue/reference/functions/shouldThrowError.md +++ b/docs/framework/vue/reference/functions/shouldThrowError.md @@ -7,7 +7,7 @@ title: shouldThrowError function shouldThrowError(throwOnError: boolean | T | undefined, params: Parameters): boolean; ``` -Defined in: [packages/query-core/src/utils.ts:582](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L582) +Defined in: [packages/query-core/src/utils.ts:687](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L687) Resolves a `throwOnError` option to a boolean. If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, @@ -27,14 +27,21 @@ resolves to `false`). `boolean` \| `T` \| `undefined` +The `throwOnError` option: a boolean, a function that decides per error, or +`undefined`. + ### params `Parameters`\<`T`\> +The arguments passed to `throwOnError` if it is a function. + ## Returns `boolean` +Whether the error should be thrown. + ## Example ```ts diff --git a/docs/framework/vue/reference/interfaces/FocusManager.md b/docs/framework/vue/reference/interfaces/FocusManager.md index 3d59e85c451..95250b0999f 100644 --- a/docs/framework/vue/reference/interfaces/FocusManager.md +++ b/docs/framework/vue/reference/interfaces/FocusManager.md @@ -21,7 +21,7 @@ It can be used to change the default event listeners or to manually change the f 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -29,6 +29,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -43,7 +45,7 @@ Subscribable.hasListeners isFocused(): boolean; ``` -Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) +Defined in: [packages/query-core/src/focusManager.ts:130](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L130) `isFocused` can be used to get the current focus state. @@ -51,6 +53,8 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan `boolean` +The focus state set with `setFocused`, or otherwise whether the document is visible. + *** ### onFocus() @@ -59,7 +63,7 @@ Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/Tan onFocus(): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) +Defined in: [packages/query-core/src/focusManager.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L119) `onFocus` notifies all subscribed listeners with the current focus state. @@ -75,7 +79,7 @@ Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/Tan setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) +Defined in: [packages/query-core/src/focusManager.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L78) `setEventListener` can be used to set a custom event listener that will be used to determine the focus state. The provided `setup` function @@ -89,6 +93,9 @@ focus state and notify subscribers. `SetupFn` +Receives the `setFocused` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -120,7 +127,7 @@ focusManager.setEventListener((handleFocus) => { setFocused(focused?: boolean): void; ``` -Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) +Defined in: [packages/query-core/src/focusManager.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L108) `setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. @@ -131,6 +138,8 @@ to fall back to the default focus check. `boolean` +The focus state, or `undefined` to use the default focus check. + #### Returns `void` @@ -158,7 +167,7 @@ focusManager.setFocused(undefined) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -174,6 +183,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/vue/reference/interfaces/OnlineManager.md b/docs/framework/vue/reference/interfaces/OnlineManager.md index 7e97e7bc137..e3e17cd2a1b 100644 --- a/docs/framework/vue/reference/interfaces/OnlineManager.md +++ b/docs/framework/vue/reference/interfaces/OnlineManager.md @@ -25,7 +25,7 @@ detect changes. 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) +Defined in: [packages/query-core/src/subscribable.ts:43](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L43) Returns `true` while at least one listener is registered, `false` once they have all unsubscribed. @@ -33,6 +33,8 @@ Returns `true` while at least one listener is registered, `false` once they have `boolean` +`true` if at least one listener is registered. + #### Inherited from ```ts @@ -47,7 +49,7 @@ Subscribable.hasListeners isOnline(): boolean; ``` -Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) +Defined in: [packages/query-core/src/onlineManager.ts:111](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L111) `isOnline` can be used to get the current online state. @@ -55,6 +57,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta `boolean` +`true` if online. + *** ### setEventListener() @@ -63,7 +67,7 @@ Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/Ta setEventListener(setup: SetupFn): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) +Defined in: [packages/query-core/src/onlineManager.ts:76](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L76) `setEventListener` can be used to set a custom event listener that will be used to determine the online state. The provided `setup` function @@ -76,6 +80,9 @@ whenever the online state changes. `SetupFn` +Receives the `setOnline` callback, registers the event listener, and may return +a cleanup function that is called when the listener is replaced or no longer needed. + #### Returns `void` @@ -101,7 +108,7 @@ onlineManager.setEventListener((setOnline) => { setOnline(online: boolean): void; ``` -Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) +Defined in: [packages/query-core/src/onlineManager.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L96) `setOnline` can be used to manually set the online state. @@ -111,6 +118,8 @@ Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/Tan `boolean` +The online state. + #### Returns `void` @@ -135,7 +144,7 @@ onlineManager.setOnline(false) subscribe(listener: Listener): () => void; ``` -Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) +Defined in: [packages/query-core/src/subscribable.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L28) 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 @@ -151,6 +160,8 @@ Called on each update, with whatever the subclass passes to its subscribers. #### Returns +A function that removes the listener. + () => `void` #### Example diff --git a/docs/framework/vue/reference/interfaces/TimeoutManager.md b/docs/framework/vue/reference/interfaces/TimeoutManager.md index 164487133a6..06477f667a2 100644 --- a/docs/framework/vue/reference/interfaces/TimeoutManager.md +++ b/docs/framework/vue/reference/interfaces/TimeoutManager.md @@ -7,7 +7,7 @@ Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/Ta Allows customization of how timeouts are created. -@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +`@tanstack/query-core` makes liberal use of timeouts to implement `staleTime` and `gcTime`. The default TimeoutManager provider uses the platform's global `setTimeout` implementation, which is known to have scalability issues with thousands of timeouts on the event loop. @@ -27,7 +27,7 @@ coalesces timeouts. clearInterval(intervalId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) +Defined in: [packages/query-core/src/timeoutManager.ts:228](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L228) `clearInterval` can be used to cancel an interval, like the global `clearInterval` function. It should be called with an interval ID @@ -39,6 +39,8 @@ returned by `setInterval`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setInterval`, or `undefined`. + #### Returns `void` @@ -70,7 +72,7 @@ Omit.clearInterval clearTimeout(timeoutId: ManagedTimerId | undefined): void; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) +Defined in: [packages/query-core/src/timeoutManager.ts:181](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L181) `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, like the global `clearTimeout` function. It should be called with a @@ -82,6 +84,8 @@ timer ID returned by `setTimeout`. [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) \| `undefined` +The timer ID returned by `setTimeout`, or `undefined`. + #### Returns `void` @@ -113,7 +117,7 @@ Omit.clearTimeout setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) +Defined in: [packages/query-core/src/timeoutManager.ts:204](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L204) `setInterval` schedules a callback to be called approximately every `delay` milliseconds, like the global `setInterval` function. @@ -127,14 +131,20 @@ object that can be coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call on every interval. + ##### delay `number` +The time between calls, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearInterval](#clearinterval). + #### Example ```ts @@ -160,7 +170,7 @@ Omit.setInterval setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId; ``` -Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) +Defined in: [packages/query-core/src/timeoutManager.ts:157](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L157) `setTimeout` schedules a callback to run after approximately `delay` milliseconds, like the global `setTimeout` function. The callback can be @@ -175,14 +185,20 @@ coerced to a number via `Symbol.toPrimitive`. [`TimeoutCallback`](../type-aliases/TimeoutCallback.md) +The function to call when the timeout elapses. + ##### delay `number` +The time to wait before calling `callback`, in milliseconds. + #### Returns [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) +The timer ID, to pass to [TimeoutManager#clearTimeout](#cleartimeout). + #### Example ```ts @@ -238,6 +254,8 @@ cannot cancel each others' timers. [`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> +The `TimeoutProvider` to use for all timers from now on. + #### Returns `void` diff --git a/docs/framework/vue/reference/variables/notifyManager.md b/docs/framework/vue/reference/variables/notifyManager.md index abc590e3442..1358af7c7d4 100644 --- a/docs/framework/vue/reference/variables/notifyManager.md +++ b/docs/framework/vue/reference/variables/notifyManager.md @@ -7,7 +7,7 @@ title: notifyManager const notifyManager: object; ``` -Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) +Defined in: [packages/query-core/src/notifyManager.ts:154](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L154) Handles scheduling and batching callbacks in TanStack Query. @@ -36,10 +36,14 @@ The return value of `callback` is passed through. () => `T` +The function to run in the batch. + #### Returns `T` +The return value of `callback`. + ### batchCalls ```ts @@ -60,10 +64,14 @@ All calls to the wrapped function will be batched. `BatchCallsCallback`\<`T`\> +The function to wrap. + #### Returns `BatchCallsCallback`\<`T`\> +A function that schedules a call to `callback` with the given arguments. + ### schedule ```ts @@ -99,6 +107,8 @@ update only triggers one re-render instead of one per subscriber. `BatchNotifyFunction` +Receives a function that runs a batch of notifications and must call it. + #### Returns `void` @@ -127,6 +137,8 @@ This can be used to for example wrap notifications with `React.act` while runnin `NotifyFunction` +Receives each notification callback and must call it. + #### Returns `void` @@ -146,6 +158,8 @@ The default behavior is `setTimeout(callback, 0)`. `ScheduleFunction` +Receives a callback that runs the next batch, and schedules it. + #### Returns `void` From dd78028ab390e79158bae9a7605b066020b007a6 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Mon, 5 Oct 2026 04:10:10 +0900 Subject: [PATCH 4/4] docs(framework/*/reference): regenerate reference docs --- .../interfaces/BaseMutationNarrowing.md | 14 +++++----- .../interfaces/BaseQueryNarrowing.md | 10 +++---- .../reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../reference/interfaces/NotifyEvent.md | 8 +++--- .../interfaces/QueryExecuteOptions.md | 4 +-- .../reference/interfaces/QueryFeature.md | 8 +++--- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- .../lit/reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../lit/reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../lit/reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../lit/reference/interfaces/NotifyEvent.md | 8 +++--- .../interfaces/QueryExecuteOptions.md | 4 +-- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../lit/reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- .../reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../reference/interfaces/NotifyEvent.md | 8 +++--- .../interfaces/QueryExecuteOptions.md | 4 +-- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- .../reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../react/reference/interfaces/NotifyEvent.md | 8 +++--- .../interfaces/QueryExecuteOptions.md | 4 +-- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- .../reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../solid/reference/interfaces/NotifyEvent.md | 8 +++--- .../reference/interfaces/QueryClientConfig.md | 4 +-- .../interfaces/QueryExecuteOptions.md | 4 +-- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- .../reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../reference/interfaces/NotifyEvent.md | 8 +++--- .../interfaces/QueryExecuteOptions.md | 4 +-- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/MutationStateOptions.md | 8 +++--- .../type-aliases/QueryClientProviderProps.md | 10 +++---- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- .../vue/reference/interfaces/CancelOptions.md | 10 +++---- .../reference/interfaces/DefaultOptions.md | 4 +-- .../reference/interfaces/DehydratedState.md | 8 +++--- .../interfaces/EnsureQueryDataOptions.md | 6 ++--- .../reference/interfaces/FetchQueryOptions.md | 4 +-- .../vue/reference/interfaces/InfiniteData.md | 10 +++---- ...InfiniteQueryObserverLoadingErrorResult.md | 26 +++++++++---------- .../InfiniteQueryObserverLoadingResult.md | 26 +++++++++---------- .../InfiniteQueryObserverPendingResult.md | 24 ++++++++--------- .../InfiniteQueryObserverPlaceholderResult.md | 26 +++++++++---------- ...InfiniteQueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../InfiniteQueryObserverSuccessResult.md | 24 ++++++++--------- .../vue/reference/interfaces/MutateOptions.md | 12 ++++----- .../interfaces/MutationObserverErrorResult.md | 18 ++++++------- .../interfaces/MutationObserverIdleResult.md | 18 ++++++------- .../MutationObserverLoadingResult.md | 18 ++++++------- .../MutationObserverSuccessResult.md | 18 ++++++------- .../vue/reference/interfaces/NotifyEvent.md | 8 +++--- .../interfaces/QueryExecuteOptions.md | 4 +-- .../QueryObserverLoadingErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverLoadingResult.md | 22 ++++++++-------- .../interfaces/QueryObserverPendingResult.md | 20 +++++++------- .../QueryObserverPlaceholderResult.md | 22 ++++++++-------- .../QueryObserverRefetchErrorResult.md | 22 ++++++++-------- .../interfaces/QueryObserverSuccessResult.md | 20 +++++++------- .../reference/interfaces/SetDataOptions.md | 8 +++--- .../vue/reference/type-aliases/AnyDataTag.md | 8 +++--- .../type-aliases/MutationFunctionContext.md | 12 ++++----- .../reference/type-aliases/MutationScope.md | 8 +++--- .../type-aliases/MutationStateOptions.md | 8 +++--- .../type-aliases/QueryKeyWithDataTag.md | 8 +++--- .../reference/type-aliases/TimeoutProvider.md | 12 ++++----- 224 files changed, 1676 insertions(+), 1676 deletions(-) diff --git a/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md b/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md index ff7ec08f21b..c59d49ada8f 100644 --- a/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md +++ b/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md @@ -3,7 +3,7 @@ id: BaseMutationNarrowing title: BaseMutationNarrowing --- -Defined in: [packages/angular-query-experimental/src/types.ts:315](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L315) +Defined in: [packages/angular-query-experimental/src/types.ts:324](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L324) The `isSuccess`/`isError`/`isPending`/`isIdle` methods on a mutation result. Each is both a `Signal` (its current boolean value is read reactively without calling it) and a type-guard function you can @@ -38,9 +38,9 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. ## Properties -| Property | Type | -| ------ | ------ | -| `isError` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | -| `isIdle` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | -| `isPending` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | -| `isSuccess` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `isError` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | Whether the mutation is in the `error` state. Calling it narrows the result to that state. | +| `isIdle` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | Whether the mutation is in the `idle` state. Calling it narrows the result to that state. | +| `isPending` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | Whether the mutation is in the `pending` state. Calling it narrows the result to that state. | +| `isSuccess` | `SignalFunction`\<(`this`: [`CreateMutationResult`](../type-aliases/CreateMutationResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>`\> | Whether the mutation is in the `success` state. Calling it narrows the result to that state. | diff --git a/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md b/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md index 0bb6005038c..122cf505dd9 100644 --- a/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md +++ b/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md @@ -26,8 +26,8 @@ The type of errors your `queryFn` may throw. ## Properties -| Property | Type | -| ------ | ------ | -| `isError` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | -| `isPending` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | -| `isSuccess` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `isError` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | Returns `true` if the query is in the `error` state, narrowing the result to that state. | +| `isPending` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | Returns `true` if the query is in the `pending` state, narrowing the result to that state. | +| `isSuccess` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult>` | Returns `true` if the query is in the `success` state, narrowing the result to that state. | diff --git a/docs/framework/angular/reference/interfaces/CancelOptions.md b/docs/framework/angular/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/angular/reference/interfaces/CancelOptions.md +++ b/docs/framework/angular/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/angular/reference/interfaces/DefaultOptions.md b/docs/framework/angular/reference/interfaces/DefaultOptions.md index f93c420f812..58c0f5752b4 100644 --- a/docs/framework/angular/reference/interfaces/DefaultOptions.md +++ b/docs/framework/angular/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [packages/query-core/src/types.ts:1841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1841) +Defined in: [packages/query-core/src/types.ts:2371](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2371) The default options of a `QueryClient`, applied to every query (`queries`), mutation (`mutations`), `hydrate`, and `dehydrate` call unless overridden. @@ -19,7 +19,7 @@ The default options of a `QueryClient`, applied to every query (`queries`), muta | Property | Type | Description | | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/angular/reference/interfaces/DehydratedState.md b/docs/framework/angular/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/angular/reference/interfaces/DehydratedState.md +++ b/docs/framework/angular/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/angular/reference/interfaces/FetchQueryOptions.md b/docs/framework/angular/reference/interfaces/FetchQueryOptions.md index 334630aea6d..184ecf31eb3 100644 --- a/docs/framework/angular/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/angular/reference/interfaces/InfiniteData.md b/docs/framework/angular/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteData.md +++ b/docs/framework/angular/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/MutateOptions.md b/docs/framework/angular/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/angular/reference/interfaces/MutateOptions.md +++ b/docs/framework/angular/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/angular/reference/interfaces/NotifyEvent.md b/docs/framework/angular/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/angular/reference/interfaces/NotifyEvent.md +++ b/docs/framework/angular/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md b/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md index 6a2507c5863..4be94151778 100644 --- a/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/angular/reference/interfaces/QueryFeature.md b/docs/framework/angular/reference/interfaces/QueryFeature.md index a659e911a62..6b6a80fd779 100644 --- a/docs/framework/angular/reference/interfaces/QueryFeature.md +++ b/docs/framework/angular/reference/interfaces/QueryFeature.md @@ -15,7 +15,7 @@ Helper type to represent a Query feature. ## Properties -| Property | Type | -| ------ | ------ | -| `ɵkind` | `TFeatureKind` | -| `ɵproviders` | `Provider`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `ɵkind` | `TFeatureKind` | The kind of the feature, e.g. `'Devtools'` or `'PersistQueryClient'`. | +| `ɵproviders` | `Provider`[] | The providers that `provideTanStackQuery` registers for the feature. | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/angular/reference/interfaces/SetDataOptions.md b/docs/framework/angular/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/angular/reference/interfaces/SetDataOptions.md +++ b/docs/framework/angular/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/angular/reference/type-aliases/AnyDataTag.md b/docs/framework/angular/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/angular/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/angular/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md b/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md index c0dfe1b6012..d63d9033cd7 100644 --- a/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | [`QueryClient`](../classes/QueryClient.md) | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/angular/reference/type-aliases/MutationScope.md b/docs/framework/angular/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/angular/reference/type-aliases/MutationScope.md +++ b/docs/framework/angular/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/angular/reference/type-aliases/TimeoutProvider.md b/docs/framework/angular/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/angular/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/angular/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. | diff --git a/docs/framework/lit/reference/interfaces/CancelOptions.md b/docs/framework/lit/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/lit/reference/interfaces/CancelOptions.md +++ b/docs/framework/lit/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/lit/reference/interfaces/DefaultOptions.md b/docs/framework/lit/reference/interfaces/DefaultOptions.md index f93c420f812..58c0f5752b4 100644 --- a/docs/framework/lit/reference/interfaces/DefaultOptions.md +++ b/docs/framework/lit/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [packages/query-core/src/types.ts:1841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1841) +Defined in: [packages/query-core/src/types.ts:2371](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2371) The default options of a `QueryClient`, applied to every query (`queries`), mutation (`mutations`), `hydrate`, and `dehydrate` call unless overridden. @@ -19,7 +19,7 @@ The default options of a `QueryClient`, applied to every query (`queries`), muta | Property | Type | Description | | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/lit/reference/interfaces/DehydratedState.md b/docs/framework/lit/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/lit/reference/interfaces/DehydratedState.md +++ b/docs/framework/lit/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/lit/reference/interfaces/FetchQueryOptions.md b/docs/framework/lit/reference/interfaces/FetchQueryOptions.md index 334630aea6d..184ecf31eb3 100644 --- a/docs/framework/lit/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/lit/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/lit/reference/interfaces/InfiniteData.md b/docs/framework/lit/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteData.md +++ b/docs/framework/lit/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/MutateOptions.md b/docs/framework/lit/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/lit/reference/interfaces/MutateOptions.md +++ b/docs/framework/lit/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/lit/reference/interfaces/NotifyEvent.md b/docs/framework/lit/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/lit/reference/interfaces/NotifyEvent.md +++ b/docs/framework/lit/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md b/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md index 6a2507c5863..4be94151778 100644 --- a/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/lit/reference/interfaces/SetDataOptions.md b/docs/framework/lit/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/lit/reference/interfaces/SetDataOptions.md +++ b/docs/framework/lit/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/lit/reference/type-aliases/AnyDataTag.md b/docs/framework/lit/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/lit/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/lit/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md b/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md index c0dfe1b6012..d63d9033cd7 100644 --- a/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | [`QueryClient`](../classes/QueryClient.md) | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/lit/reference/type-aliases/MutationScope.md b/docs/framework/lit/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/lit/reference/type-aliases/MutationScope.md +++ b/docs/framework/lit/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/lit/reference/type-aliases/TimeoutProvider.md b/docs/framework/lit/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/lit/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/lit/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. | diff --git a/docs/framework/preact/reference/interfaces/CancelOptions.md b/docs/framework/preact/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/preact/reference/interfaces/CancelOptions.md +++ b/docs/framework/preact/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/preact/reference/interfaces/DefaultOptions.md b/docs/framework/preact/reference/interfaces/DefaultOptions.md index f93c420f812..58c0f5752b4 100644 --- a/docs/framework/preact/reference/interfaces/DefaultOptions.md +++ b/docs/framework/preact/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [packages/query-core/src/types.ts:1841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1841) +Defined in: [packages/query-core/src/types.ts:2371](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2371) The default options of a `QueryClient`, applied to every query (`queries`), mutation (`mutations`), `hydrate`, and `dehydrate` call unless overridden. @@ -19,7 +19,7 @@ The default options of a `QueryClient`, applied to every query (`queries`), muta | Property | Type | Description | | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/preact/reference/interfaces/DehydratedState.md b/docs/framework/preact/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/preact/reference/interfaces/DehydratedState.md +++ b/docs/framework/preact/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/preact/reference/interfaces/FetchQueryOptions.md b/docs/framework/preact/reference/interfaces/FetchQueryOptions.md index 334630aea6d..184ecf31eb3 100644 --- a/docs/framework/preact/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/preact/reference/interfaces/InfiniteData.md b/docs/framework/preact/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteData.md +++ b/docs/framework/preact/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/MutateOptions.md b/docs/framework/preact/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/preact/reference/interfaces/MutateOptions.md +++ b/docs/framework/preact/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/preact/reference/interfaces/NotifyEvent.md b/docs/framework/preact/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/preact/reference/interfaces/NotifyEvent.md +++ b/docs/framework/preact/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md b/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md index 6a2507c5863..4be94151778 100644 --- a/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/preact/reference/interfaces/SetDataOptions.md b/docs/framework/preact/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/preact/reference/interfaces/SetDataOptions.md +++ b/docs/framework/preact/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/preact/reference/type-aliases/AnyDataTag.md b/docs/framework/preact/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/preact/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/preact/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md b/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md index c0dfe1b6012..d63d9033cd7 100644 --- a/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | [`QueryClient`](../classes/QueryClient.md) | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/preact/reference/type-aliases/MutationScope.md b/docs/framework/preact/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/preact/reference/type-aliases/MutationScope.md +++ b/docs/framework/preact/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/preact/reference/type-aliases/TimeoutProvider.md b/docs/framework/preact/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/preact/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/preact/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. | diff --git a/docs/framework/react/reference/interfaces/CancelOptions.md b/docs/framework/react/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/react/reference/interfaces/CancelOptions.md +++ b/docs/framework/react/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/react/reference/interfaces/DefaultOptions.md b/docs/framework/react/reference/interfaces/DefaultOptions.md index f93c420f812..58c0f5752b4 100644 --- a/docs/framework/react/reference/interfaces/DefaultOptions.md +++ b/docs/framework/react/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [packages/query-core/src/types.ts:1841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1841) +Defined in: [packages/query-core/src/types.ts:2371](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2371) The default options of a `QueryClient`, applied to every query (`queries`), mutation (`mutations`), `hydrate`, and `dehydrate` call unless overridden. @@ -19,7 +19,7 @@ The default options of a `QueryClient`, applied to every query (`queries`), muta | Property | Type | Description | | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/react/reference/interfaces/DehydratedState.md b/docs/framework/react/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/react/reference/interfaces/DehydratedState.md +++ b/docs/framework/react/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/react/reference/interfaces/FetchQueryOptions.md b/docs/framework/react/reference/interfaces/FetchQueryOptions.md index 334630aea6d..184ecf31eb3 100644 --- a/docs/framework/react/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/react/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/react/reference/interfaces/InfiniteData.md b/docs/framework/react/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/react/reference/interfaces/InfiniteData.md +++ b/docs/framework/react/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/MutateOptions.md b/docs/framework/react/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/react/reference/interfaces/MutateOptions.md +++ b/docs/framework/react/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/react/reference/interfaces/NotifyEvent.md b/docs/framework/react/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/react/reference/interfaces/NotifyEvent.md +++ b/docs/framework/react/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/react/reference/interfaces/QueryExecuteOptions.md b/docs/framework/react/reference/interfaces/QueryExecuteOptions.md index 6a2507c5863..4be94151778 100644 --- a/docs/framework/react/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/react/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/react/reference/interfaces/SetDataOptions.md b/docs/framework/react/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/react/reference/interfaces/SetDataOptions.md +++ b/docs/framework/react/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/react/reference/type-aliases/AnyDataTag.md b/docs/framework/react/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/react/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/react/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/react/reference/type-aliases/MutationFunctionContext.md b/docs/framework/react/reference/type-aliases/MutationFunctionContext.md index c0dfe1b6012..d63d9033cd7 100644 --- a/docs/framework/react/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/react/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | [`QueryClient`](../classes/QueryClient.md) | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/react/reference/type-aliases/MutationScope.md b/docs/framework/react/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/react/reference/type-aliases/MutationScope.md +++ b/docs/framework/react/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/react/reference/type-aliases/TimeoutProvider.md b/docs/framework/react/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/react/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/react/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. | diff --git a/docs/framework/solid/reference/interfaces/CancelOptions.md b/docs/framework/solid/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/solid/reference/interfaces/CancelOptions.md +++ b/docs/framework/solid/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/solid/reference/interfaces/DefaultOptions.md b/docs/framework/solid/reference/interfaces/DefaultOptions.md index 88c97ff34f4..6f3e545256d 100644 --- a/docs/framework/solid/reference/interfaces/DefaultOptions.md +++ b/docs/framework/solid/reference/interfaces/DefaultOptions.md @@ -25,9 +25,9 @@ The default type of errors thrown by queries and mutations using this `QueryClie | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | - | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | - | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | - | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | - | | `hydrate.mutations?` | `MutationOptions`\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | - | | `hydrate.queries?` | `QueryOptions`\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | - | | `mutations?` | [`MutationObserverOptions`](MutationObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`\> | Default options applied to every mutation, unless overridden per-mutation. | - | -| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"`\> | Default options applied to every query, unless overridden per-query. | `CoreDefaultOptions.queries` | +| `queries?` | [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`unknown`, `TError`, `unknown`, `unknown`, readonly `unknown`[], `never`\>, `"queryKey"`\> | Default options applied to every query, unless overridden per-query, including Solid's `reconcile` option. | `CoreDefaultOptions.queries` | diff --git a/docs/framework/solid/reference/interfaces/DehydratedState.md b/docs/framework/solid/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/solid/reference/interfaces/DehydratedState.md +++ b/docs/framework/solid/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/solid/reference/interfaces/FetchQueryOptions.md b/docs/framework/solid/reference/interfaces/FetchQueryOptions.md index 862498abe58..be94836fca3 100644 --- a/docs/framework/solid/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/solid/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/solid/reference/interfaces/InfiniteData.md b/docs/framework/solid/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteData.md +++ b/docs/framework/solid/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/MutateOptions.md b/docs/framework/solid/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/solid/reference/interfaces/MutateOptions.md +++ b/docs/framework/solid/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/solid/reference/interfaces/NotifyEvent.md b/docs/framework/solid/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/solid/reference/interfaces/NotifyEvent.md +++ b/docs/framework/solid/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/solid/reference/interfaces/QueryClientConfig.md b/docs/framework/solid/reference/interfaces/QueryClientConfig.md index 262d20e3cbe..4f1ae84b26e 100644 --- a/docs/framework/solid/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/solid/reference/interfaces/QueryClientConfig.md @@ -3,7 +3,7 @@ id: QueryClientConfig title: QueryClientConfig --- -Defined in: [packages/solid-query/src/QueryClient.ts:98](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L98) +Defined in: [packages/solid-query/src/QueryClient.ts:102](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L102) The config accepted by `new QueryClient(config)`, with Solid's extended [DefaultOptions](DefaultOptions.md). @@ -15,6 +15,6 @@ The config accepted by `new QueryClient(config)`, with Solid's extended [Default | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | Default options for all queries and mutations created through this client. | `QueryCoreClientConfig.defaultOptions` | +| `defaultOptions?` | [`DefaultOptions`](DefaultOptions.md)\<`Error`\> | The default options of the queries and mutations of this `QueryClient`. | `QueryCoreClientConfig.defaultOptions` | | `mutationCache?` | [`MutationCache`](../classes/MutationCache.md) | The mutation cache this client is connected to. A new `MutationCache` is created if not provided. | - | | `queryCache?` | [`QueryCache`](../classes/QueryCache.md) | The query cache this client is connected to. A new `QueryCache` is created if not provided. | - | diff --git a/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md b/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md index eb9ee98dbcf..18340c5ab90 100644 --- a/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/solid/reference/interfaces/SetDataOptions.md b/docs/framework/solid/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/solid/reference/interfaces/SetDataOptions.md +++ b/docs/framework/solid/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/solid/reference/type-aliases/AnyDataTag.md b/docs/framework/solid/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/solid/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/solid/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md b/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md index 9f4798c3729..d90605783fb 100644 --- a/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | `QueryClient` | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | `QueryClient` | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/solid/reference/type-aliases/MutationScope.md b/docs/framework/solid/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/solid/reference/type-aliases/MutationScope.md +++ b/docs/framework/solid/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/solid/reference/type-aliases/TimeoutProvider.md b/docs/framework/solid/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/solid/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/solid/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. | diff --git a/docs/framework/svelte/reference/interfaces/CancelOptions.md b/docs/framework/svelte/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/svelte/reference/interfaces/CancelOptions.md +++ b/docs/framework/svelte/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/svelte/reference/interfaces/DefaultOptions.md b/docs/framework/svelte/reference/interfaces/DefaultOptions.md index f93c420f812..58c0f5752b4 100644 --- a/docs/framework/svelte/reference/interfaces/DefaultOptions.md +++ b/docs/framework/svelte/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [packages/query-core/src/types.ts:1841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1841) +Defined in: [packages/query-core/src/types.ts:2371](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2371) The default options of a `QueryClient`, applied to every query (`queries`), mutation (`mutations`), `hydrate`, and `dehydrate` call unless overridden. @@ -19,7 +19,7 @@ The default options of a `QueryClient`, applied to every query (`queries`), muta | Property | Type | Description | | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | [`MutationOptions`](MutationOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | [`QueryOptions`](QueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/svelte/reference/interfaces/DehydratedState.md b/docs/framework/svelte/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/svelte/reference/interfaces/DehydratedState.md +++ b/docs/framework/svelte/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md b/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md index 334630aea6d..184ecf31eb3 100644 --- a/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteData.md b/docs/framework/svelte/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteData.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/MutateOptions.md b/docs/framework/svelte/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/svelte/reference/interfaces/MutateOptions.md +++ b/docs/framework/svelte/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/svelte/reference/interfaces/NotifyEvent.md b/docs/framework/svelte/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/svelte/reference/interfaces/NotifyEvent.md +++ b/docs/framework/svelte/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md b/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md index 6a2507c5863..4be94151778 100644 --- a/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/svelte/reference/interfaces/SetDataOptions.md b/docs/framework/svelte/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/svelte/reference/interfaces/SetDataOptions.md +++ b/docs/framework/svelte/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/svelte/reference/type-aliases/AnyDataTag.md b/docs/framework/svelte/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/svelte/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/svelte/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md b/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md index c0dfe1b6012..d63d9033cd7 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | [`QueryClient`](../classes/QueryClient.md) | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | [`QueryClient`](../classes/QueryClient.md) | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/svelte/reference/type-aliases/MutationScope.md b/docs/framework/svelte/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationScope.md +++ b/docs/framework/svelte/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md b/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md index 89752a25116..4af84918fef 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md @@ -23,7 +23,7 @@ Options for useMutationState ## Properties -| Property | Type | -| ------ | ------ | -| `filters?` | [`MutationFilters`](../interfaces/MutationFilters.md) | -| `select?` | (`mutation`: `TMutation`) => `TResult` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `filters?` | [`MutationFilters`](../interfaces/MutationFilters.md) | The filters that select the mutations to return the state of. | +| `select?` | (`mutation`: `TMutation`) => `TResult` | Maps each matching mutation to the value returned for it. Defaults to the mutation's `state`. | diff --git a/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md index 4e410c89aef..faef2fd84a5 100644 --- a/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/svelte/reference/type-aliases/QueryClientProviderProps.md @@ -7,13 +7,13 @@ title: QueryClientProviderProps type QueryClientProviderProps = object; ``` -Defined in: [packages/svelte-query/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/types.ts#L192) +Defined in: [packages/svelte-query/src/types.ts:198](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/types.ts#L198) The props accepted by `QueryClientProvider`. ## Properties -| Property | Type | -| ------ | ------ | -| `children` | `Snippet` | -| `client` | [`QueryClient`](../classes/QueryClient.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `children` | `Snippet` | The children that can use the provided `QueryClient`. | +| `client` | [`QueryClient`](../classes/QueryClient.md) | The `QueryClient` to provide to the children. | diff --git a/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md b/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. | diff --git a/docs/framework/vue/reference/interfaces/CancelOptions.md b/docs/framework/vue/reference/interfaces/CancelOptions.md index 33d9820bcbc..145bb74fb42 100644 --- a/docs/framework/vue/reference/interfaces/CancelOptions.md +++ b/docs/framework/vue/reference/interfaces/CancelOptions.md @@ -3,14 +3,14 @@ id: CancelOptions title: CancelOptions --- -Defined in: [packages/query-core/src/types.ts:1859](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1859) +Defined in: [packages/query-core/src/types.ts:2389](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2389) Options for cancelling an in-flight fetch, e.g. via `query.cancel()`. They are carried on the [CancelledError](../classes/CancelledError.md) that the cancelled fetch rejects with. ## Properties -| Property | Type | -| ------ | ------ | -| `revert?` | `boolean` | -| `silent?` | `boolean` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `revert?` | `boolean` | If `true`, the query goes back to the state it had before the fetch started, instead of getting the cancellation error. | +| `silent?` | `boolean` | If `true`, the cancellation error isn't surfaced, e.g. because another fetch replaces the cancelled one. | diff --git a/docs/framework/vue/reference/interfaces/DefaultOptions.md b/docs/framework/vue/reference/interfaces/DefaultOptions.md index 388a79537ad..cb32db080e0 100644 --- a/docs/framework/vue/reference/interfaces/DefaultOptions.md +++ b/docs/framework/vue/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [packages/query-core/src/types.ts:1841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1841) +Defined in: [packages/query-core/src/types.ts:2371](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2371) The default options of a `QueryClient`, applied to every query (`queries`), mutation (`mutations`), `hydrate`, and `dehydrate` call unless overridden. @@ -19,7 +19,7 @@ The default options of a `QueryClient`, applied to every query (`queries`), muta | Property | Type | Description | | ------ | ------ | ------ | | `dehydrate?` | [`DehydrateOptions`](DehydrateOptions.md) | Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). | -| `hydrate?` | `object` | Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). | +| `hydrate?` | `object` | Default options used when hydrating queries and mutations; see [HydrateOptions](HydrateOptions.md). | | `hydrate.deserializeData?` | `TransformerFn` | Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. | | `hydrate.mutations?` | `MutationOptions`\<`unknown`, `Error`, `unknown`, `unknown`\> | Default options merged into every mutation restored from the dehydrated state. | | `hydrate.queries?` | `QueryOptions`\<`unknown`, `Error`, `unknown`, readonly `unknown`[], `never`\> | Default options merged into every query restored from the dehydrated state. | diff --git a/docs/framework/vue/reference/interfaces/DehydratedState.md b/docs/framework/vue/reference/interfaces/DehydratedState.md index c833d4989ea..ccffae9b7fc 100644 --- a/docs/framework/vue/reference/interfaces/DehydratedState.md +++ b/docs/framework/vue/reference/interfaces/DehydratedState.md @@ -11,7 +11,7 @@ that has already been fetched, avoiding a redundant fetch on the client. ## Properties -| Property | Type | -| ------ | ------ | -| `mutations` | `DehydratedMutation`[] | -| `queries` | `DehydratedQuery`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `mutations` | `DehydratedMutation`[] | The dehydrated mutations, by default only the paused ones. | +| `queries` | `DehydratedQuery`[] | The dehydrated queries, by default only the successful ones. | diff --git a/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md index 83bb6b4e2a4..45ff9d35822 100644 --- a/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md +++ b/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md @@ -3,7 +3,7 @@ id: EnsureQueryDataOptions title: EnsureQueryDataOptions --- -Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L750) +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) ## Deprecated @@ -40,7 +40,7 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | @@ -51,6 +51,6 @@ Defined in: [packages/query-core/src/types.ts:750](https://github.com/TanStack/q | ~~`queryKeyHashFn?`~~ | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. | | ~~`retry?`~~ | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. | | ~~`retryDelay?`~~ | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. | -| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | - | +| ~~`revalidateIfStale?`~~ | `boolean` | `undefined` | If `true`, stale cached data is returned and also refetched in the background. | | ~~`staleTime?`~~ | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>) => `number` \| `"static"`) | `undefined` | The time in milliseconds after data is considered stale. If the data is fresh it will be returned from the cache. | | ~~`structuralSharing?`~~ | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. | diff --git a/docs/framework/vue/reference/interfaces/FetchQueryOptions.md b/docs/framework/vue/reference/interfaces/FetchQueryOptions.md index 862498abe58..be94836fca3 100644 --- a/docs/framework/vue/reference/interfaces/FetchQueryOptions.md +++ b/docs/framework/vue/reference/interfaces/FetchQueryOptions.md @@ -3,7 +3,7 @@ id: FetchQueryOptions title: FetchQueryOptions --- -Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L731) +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) ## Deprecated @@ -44,7 +44,7 @@ Defined in: [packages/query-core/src/types.ts:731](https://github.com/TanStack/q | ~~`gcTime?`~~ | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | ~~`initialData?`~~ | `TData` \| (() => `TData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | ~~`initialDataUpdatedAt?`~~ | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| ~~`initialPageParam?`~~ | `undefined` | `undefined` | - | +| ~~`initialPageParam?`~~ | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | ~~`maxPages?`~~ | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | ~~`meta?`~~ | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | ~~`networkMode?`~~ | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/vue/reference/interfaces/InfiniteData.md b/docs/framework/vue/reference/interfaces/InfiniteData.md index bd088febbd9..c508d248352 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteData.md +++ b/docs/framework/vue/reference/interfaces/InfiniteData.md @@ -3,7 +3,7 @@ id: InfiniteData title: InfiniteData --- -Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) +Defined in: [packages/query-core/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L313) The data shape of an infinite query: every page fetched so far, plus the page param each one was fetched with. `pages` and `pageParams` are index-aligned — `pageParams[i]` is the param that produced `pages[i]`. @@ -20,7 +20,7 @@ The data shape of an infinite query: every page fetched so far, plus the page pa ## Properties -| Property | Type | -| ------ | ------ | -| `pageParams` | `TPageParam`[] | -| `pages` | `TData`[] | +| Property | Type | Description | +| ------ | ------ | ------ | +| `pageParams` | `TPageParam`[] | The page param each page was fetched with, aligned by index with `pages`. | +| `pages` | `TData`[] | The data of every page fetched so far, in order. | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md index c4becb3fd68..13788b771f8 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingErrorResult title: InfiniteQueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1287](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1287) +Defined in: [packages/query-core/src/types.ts:1559](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1559) An infinite query result in the `error` state when the first fetch failed, so there is no data. @@ -25,9 +25,9 @@ An infinite query result in the `error` state when the first fetch failed, so th | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `error` state when the first fetch failed, so th | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md index 0f566c2aa22..3a8953f65f5 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverLoadingResult title: InfiniteQueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1266](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1266) +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) An infinite query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,9 +26,9 @@ An infinite query result in the `pending` state while the first fetch is in flig | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ An infinite query result in the `pending` state while the first fetch is in flig | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md index 773e3ac4736..02009b1610a 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPendingResult title: InfiniteQueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1245](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1245) +Defined in: [packages/query-core/src/types.ts:1448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1448) An infinite query result in the `pending` state: the query has no data yet. @@ -25,9 +25,9 @@ An infinite query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `pending` state: the query has no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md index 1f01af7e18c..1252c9e11d9 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverPlaceholderResult title: InfiniteQueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1350](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1350) +Defined in: [packages/query-core/src/types.ts:1725](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1725) An infinite query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,9 +26,9 @@ no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,23 +39,23 @@ no data yet. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md index 7262e481908..b35f0580f1e 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverRefetchErrorResult title: InfiniteQueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1309](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1309) +Defined in: [packages/query-core/src/types.ts:1617](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1617) An infinite query result in the `error` state when a refetch failed, so the data from before is kept. @@ -26,9 +26,9 @@ kept. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -39,7 +39,7 @@ kept. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | @@ -48,14 +48,14 @@ kept. | `isFetchNextPageError` | `boolean` | Will be `true` if the query failed while fetching the next page. | - | | `isFetchPreviousPageError` | `boolean` | Will be `true` if the query failed while fetching the previous page. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md index 0dcbe8d15b1..1116e189fac 100644 --- a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: InfiniteQueryObserverSuccessResult title: InfiniteQueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1328](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1328) +Defined in: [packages/query-core/src/types.ts:1666](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1666) An infinite query result in the `success` state with data from the cache. @@ -27,7 +27,7 @@ An infinite query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | @@ -38,23 +38,23 @@ An infinite query result in the `success` state with data from the cache. | `hasNextPage` | `boolean` | Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). | - | | `hasPreviousPage` | `boolean` | Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | `isFetchingNextPage` | `boolean` | Will be `true` while fetching the next page with `fetchNextPage`. | - | | `isFetchingPreviousPage` | `boolean` | Will be `true` while fetching the previous page with `fetchPreviousPage`. | - | -| `isFetchNextPageError` | `false` | Will be `true` if the query failed while fetching the next page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | -| `isFetchPreviousPageError` | `false` | Will be `true` if the query failed while fetching the previous page. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | +| `isFetchNextPageError` | `false` | `false`, since fetching the next page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchnextpageerror) | +| `isFetchPreviousPageError` | `false` | `false`, since fetching the previous page didn't fail. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#property-isfetchpreviouspageerror) | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/MutateOptions.md b/docs/framework/vue/reference/interfaces/MutateOptions.md index 4d6065c2964..7dcb28daac9 100644 --- a/docs/framework/vue/reference/interfaces/MutateOptions.md +++ b/docs/framework/vue/reference/interfaces/MutateOptions.md @@ -3,7 +3,7 @@ id: MutateOptions title: MutateOptions --- -Defined in: [packages/query-core/src/types.ts:1582](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1582) +Defined in: [packages/query-core/src/types.ts:2006](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2006) The callbacks that can be passed to `mutate` for a single call. They run after the callbacks of the mutation options. @@ -28,8 +28,8 @@ the mutation options. ## Properties -| Property | Type | -| ------ | ------ | -| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | -| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call fails, after the `onError` of the mutation options. | +| `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds or fails, after the `onSettled` of the mutation options. | +| `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `void` | Called when the mutation of this call succeeds, after the `onSuccess` of the mutation options. | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md index 8f0f705aa3b..5b85c5c7001 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md @@ -3,7 +3,7 @@ id: MutationObserverErrorResult title: MutationObserverErrorResult --- -Defined in: [packages/query-core/src/types.ts:1761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1761) +Defined in: [packages/query-core/src/types.ts:2243](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2243) A mutation result in the `error` state after the mutation failed. @@ -34,17 +34,17 @@ A mutation result in the `error` state after the mutation failed. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `TError` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `TError` | The error the mutation failed with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `true` | `true`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"error"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the mutation failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md index c382664e6da..487b6f54337 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md @@ -3,7 +3,7 @@ id: MutationObserverIdleResult title: MutationObserverIdleResult --- -Defined in: [packages/query-core/src/types.ts:1713](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1713) +Defined in: [packages/query-core/src/types.ts:2147](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2147) A mutation result in the `idle` state: the mutation hasn't run yet, or was reset. @@ -34,17 +34,17 @@ A mutation result in the `idle` state: the mutation hasn't run yet, or was reset | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `true` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `true` | `true`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"idle"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"idle"` | `'idle'`, since the mutation hasn't run yet or was reset. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `undefined` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `undefined` | `undefined`, since the mutation hasn't run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md index ab15c19c95e..83a81e4634b 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md @@ -3,7 +3,7 @@ id: MutationObserverLoadingResult title: MutationObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1737) +Defined in: [packages/query-core/src/types.ts:2195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2195) A mutation result in the `pending` state while the mutation runs. @@ -34,17 +34,17 @@ A mutation result in the `pending` state while the mutation runs. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `undefined` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `undefined` | `undefined`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `true` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `true` | `true`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `false` | `false`, since the mutation hasn't succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"pending"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since the mutation is running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md index 9c87d9ee9fb..c6062ba5023 100644 --- a/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md +++ b/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md @@ -3,7 +3,7 @@ id: MutationObserverSuccessResult title: MutationObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1785](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1785) +Defined in: [packages/query-core/src/types.ts:2291](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2291) A mutation result in the `success` state after the mutation succeeded. @@ -34,17 +34,17 @@ A mutation result in the `success` state after the mutation succeeded. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | | `context` | `TOnMutateResult` \| `undefined` | The value returned by `onMutate`, if defined. Passed to `onSuccess`, `onError` and `onSettled` as the mutation's context. | - | -| `data` | `TData` | The last successfully resolved data for the mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | -| `error` | `null` | The error object for the mutation, if an error was encountered. - Defaults to `null`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | +| `data` | `TData` | The data the mutation resolved with. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#property-data) | +| `error` | `null` | `null`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#property-error) | | `failureCount` | `number` | The number of times the mutation function has failed for the current attempt. | - | | `failureReason` | `TError` \| `null` | The reason the current attempt failed, as reported by the retryer. | - | -| `isError` | `false` | A boolean variable derived from `status`. - `true` if the last mutation attempt resulted in an error. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | -| `isIdle` | `false` | A boolean variable derived from `status`. - `true` if the mutation is in its initial state prior to executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | +| `isError` | `false` | `false`, since the mutation hasn't failed. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#property-iserror) | +| `isIdle` | `false` | `false`, since the mutation has run. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#property-isidle) | | `isPaused` | `boolean` | Whether the mutation is currently paused (see network mode), or is waiting for another mutation with the same `scope` to finish. | - | -| `isPending` | `false` | A boolean variable derived from `status`. - `true` if the mutation is currently executing. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | -| `isSuccess` | `true` | A boolean variable derived from `status`. - `true` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | +| `isPending` | `false` | `false`, since the mutation isn't running. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#property-ispending) | +| `isSuccess` | `true` | `true`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#property-issuccess) | | `mutate` | [`MutateFunction`](../type-aliases/MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> | The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. **Param** **variables** The variables object to pass to the `mutationFn`. **Param** **options.onSuccess** This function will fire when the mutation is successful and will be passed the mutation's result. **Param** **options.onError** This function will fire if the mutation encounters an error and will be passed the error. **Param** **options.onSettled** This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. **Remarks** - If you make multiple requests, `onSuccess` will fire only after the latest call you've made. - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. | - | | `reset` | () => `void` | A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). | - | -| `status` | `"success"` | The status of the mutation. - Will be: - `idle` initial status prior to the mutation function executing. - `pending` if the mutation is currently executing. - `error` if the last mutation attempt resulted in an error. - `success` if the last mutation attempt was successful. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the mutation succeeded. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#property-status) | | `submittedAt` | `number` | The timestamp for when the mutation was submitted. | - | -| `variables` | `TVariables` | The variables object passed to the `mutationFn`. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | +| `variables` | `TVariables` | The variables passed to `mutate` for this mutation. | [`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#property-variables) | diff --git a/docs/framework/vue/reference/interfaces/NotifyEvent.md b/docs/framework/vue/reference/interfaces/NotifyEvent.md index b586610ef5b..db1fee813de 100644 --- a/docs/framework/vue/reference/interfaces/NotifyEvent.md +++ b/docs/framework/vue/reference/interfaces/NotifyEvent.md @@ -3,12 +3,12 @@ id: NotifyEvent title: NotifyEvent --- -Defined in: [packages/query-core/src/types.ts:1886](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1886) +Defined in: [packages/query-core/src/types.ts:2428](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2428) The base shape of the events that the query and mutation caches send to their listeners. ## Properties -| Property | Type | -| ------ | ------ | -| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `type` | \| `"added"` \| `"removed"` \| `"updated"` \| `"observerAdded"` \| `"observerRemoved"` \| `"observerResultsUpdated"` \| `"observerOptionsUpdated"` | The kind of event, e.g. `'added'`, `'removed'`, or `'updated'`. | diff --git a/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md b/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md index 09646106ad8..60a8b66f9c0 100644 --- a/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md +++ b/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md @@ -3,7 +3,7 @@ id: QueryExecuteOptions title: QueryExecuteOptions --- -Defined in: [packages/query-core/src/types.ts:706](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L706) +Defined in: [packages/query-core/src/types.ts:721](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L721) The options of `queryClient.query`: the [QueryOptions](../type-aliases/QueryOptions.md) of the query, plus a `staleTime` that decides whether cached data is returned instead of fetching, and a `select` that only @@ -46,7 +46,7 @@ transforms the value the call resolves with. | `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see `timeoutManager.setTimeoutProvider` for a workaround. | | `initialData?` | `TQueryData` \| (() => `TQueryData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. | | `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. | -| `initialPageParam?` | `undefined` | `undefined` | - | +| `initialPageParam?` | `undefined` | `undefined` | Not allowed here, since `initialPageParam` only applies to infinite queries. | | `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. | | `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. | | `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md index e075645526a..892c42f53f3 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingErrorResult title: QueryObserverLoadingErrorResult --- -Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) +Defined in: [packages/query-core/src/types.ts:1184](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1184) A query result in the `error` state when the first fetch failed, so there is no data. @@ -25,28 +25,28 @@ A query result in the `error` state when the first fetch failed, so there is no | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the first fetch failed before any data was cached. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the first fetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `true` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `true` | `true`, since the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md index 84c9d6632e0..f13b4bc3c71 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md @@ -3,7 +3,7 @@ id: QueryObserverLoadingResult title: QueryObserverLoadingResult --- -Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) A query result in the `pending` state while the first fetch is in flight, so `isLoading` is `true`. @@ -26,28 +26,28 @@ A query result in the `pending` state while the first fetch is in flight, so `is | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `true` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `true` | `true`, since the first fetch is in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md index 091c351b98c..02e26f6cbfc 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md @@ -3,7 +3,7 @@ id: QueryObserverPendingResult title: QueryObserverPendingResult --- -Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) A query result in the `pending` state: the query has no data yet. @@ -25,28 +25,28 @@ A query result in the `pending` state: the query has no data yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `undefined` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `undefined` | `undefined`, since the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | | `isLoading` | `boolean` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | - | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `true` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `true` | `true`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"pending"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"pending"` | `'pending'`, since there's no cached data and no query attempt has finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md index 5741346f140..a5b2f60f274 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md @@ -3,7 +3,7 @@ id: QueryObserverPlaceholderResult title: QueryObserverPlaceholderResult --- -Defined in: [packages/query-core/src/types.ts:1161](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1161) +Defined in: [packages/query-core/src/types.ts:1333](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1333) A query result in the `success` state that shows `placeholderData` while the query has no data yet. @@ -26,28 +26,28 @@ yet. | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The `placeholderData` shown while the query has no data yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `true` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `true` | `true`, since the data shown is the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md index 0c9c87fdda8..a5d0af9df9e 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -3,7 +3,7 @@ id: QueryObserverRefetchErrorResult title: QueryObserverRefetchErrorResult --- -Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) +Defined in: [packages/query-core/src/types.ts:1233](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1233) A query result in the `error` state when a refetch failed, so the data from before is kept. @@ -25,28 +25,28 @@ A query result in the `error` state when a refetch failed, so the data from befo | Property | Type | Description | Overrides | | ------ | ------ | ------ | ------ | -| `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | +| `data` | `TData` | The data from before the failed refetch, which is kept. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `TError` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `TError` | The error the refetch failed with. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `true` | `true`, since the query is in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `true` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `true` | `true`, since the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `false` | `false`, since the query isn't in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"error"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"error"` | `'error'`, since the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md index bca7dfecf13..9c0e70b6bf7 100644 --- a/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md +++ b/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md @@ -3,7 +3,7 @@ id: QueryObserverSuccessResult title: QueryObserverSuccessResult --- -Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) +Defined in: [packages/query-core/src/types.ts:1282](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1282) A query result in the `success` state with data from the cache. @@ -27,26 +27,26 @@ A query result in the `success` state with data from the cache. | ------ | ------ | ------ | ------ | | `data` | `TData` | The last successfully resolved data for the query. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#property-data) | | `dataUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"success"`. | - | -| `error` | `null` | The error object for the query, if an error was thrown. - Defaults to `null`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | +| `error` | `null` | `null`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#property-error) | | `errorUpdateCount` | `number` | The sum of all errors. | - | | `errorUpdatedAt` | `number` | The timestamp for when the query most recently returned the `status` as `"error"`. | - | | `failureCount` | `number` | The failure count for the query. - Incremented every time the query fails. - Reset to `0` when the query succeeds. | - | | `failureReason` | `TError` \| `null` | The failure reason for the query retry. - Reset to `null` when the query succeeds. | - | | `fetchStatus` | `"fetching"` \| `"paused"` \| `"idle"` | The fetch status of the query. - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. - `paused`: The query wanted to fetch, but has been `paused`. - `idle`: The query is not fetching. - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. | - | | `isEnabled` | `boolean` | `true` if this observer is enabled, `false` otherwise. | - | -| `isError` | `false` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query attempt resulted in an error. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | +| `isError` | `false` | `false`, since the query isn't in the `error` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#property-iserror) | | `isFetched` | `boolean` | Will be `true` if the query has been fetched. | - | | `isFetchedAfterMount` | `boolean` | Will be `true` if the query has been fetched after the component mounted. - This property can be used to not show any previously cached data. | - | | `isFetching` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. | - | | ~~`isInitialLoading`~~ | `boolean` | **Deprecated** `isInitialLoading` is being deprecated in favor of `isLoading` and will be removed in the next major version. | - | -| `isLoading` | `false` | Is `true` whenever the first fetch for a query is in-flight. - Is the same as `isFetching && isPending`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | -| `isLoadingError` | `false` | Will be `true` if the query failed while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | +| `isLoading` | `false` | `false`, since the first fetch isn't in flight. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#property-isloading) | +| `isLoadingError` | `false` | `false`, since the query didn't fail while fetching for the first time. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#property-isloadingerror) | | `isPaused` | `boolean` | A derived boolean from the `fetchStatus` variable, provided for convenience. - The query wanted to fetch, but has been `paused`. | - | -| `isPending` | `false` | Will be `pending` if there's no cached data and no query attempt was finished yet. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | -| `isPlaceholderData` | `false` | Will be `true` if the data shown is the placeholder data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | -| `isRefetchError` | `false` | Will be `true` if the query failed while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | +| `isPending` | `false` | `false`, since the query has data or a query attempt has finished. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#property-ispending) | +| `isPlaceholderData` | `false` | `false`, since the data shown isn't the `placeholderData`. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#property-isplaceholderdata) | +| `isRefetchError` | `false` | `false`, since the query didn't fail while refetching. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#property-isrefetcherror) | | `isRefetching` | `boolean` | Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. - Is the same as `isFetching && !isPending`. | - | | `isStale` | `boolean` | Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. | - | -| `isSuccess` | `true` | A derived boolean from the `status` variable, provided for convenience. - `true` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | +| `isSuccess` | `true` | `true`, since the query is in the `success` state. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#property-issuccess) | | `refetch` | (`options?`: [`RefetchOptions`](RefetchOptions.md)) => `Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> | A function to manually refetch the query. | - | -| `status` | `"success"` | The status of the query. - Will be: - `pending` if there's no cached data and no query attempt was finished yet. - `error` if the query attempt resulted in an error. - `success` if the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | +| `status` | `"success"` | `'success'`, since the query has received a response with no errors and is ready to display its data. | [`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#property-status) | diff --git a/docs/framework/vue/reference/interfaces/SetDataOptions.md b/docs/framework/vue/reference/interfaces/SetDataOptions.md index 8a653b60ad6..cf9f6037ccb 100644 --- a/docs/framework/vue/reference/interfaces/SetDataOptions.md +++ b/docs/framework/vue/reference/interfaces/SetDataOptions.md @@ -3,7 +3,7 @@ id: SetDataOptions title: SetDataOptions --- -Defined in: [packages/query-core/src/types.ts:1869](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1869) +Defined in: [packages/query-core/src/types.ts:2407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L2407) Options for writing data into the cache, e.g. via `queryClient.setQueryData()`. `updatedAt` overrides the timestamp the data is recorded with, which is what staleness is measured from; @@ -11,6 +11,6 @@ omit it to use the current time. ## Properties -| Property | Type | -| ------ | ------ | -| `updatedAt?` | `number` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `updatedAt?` | `number` | The timestamp to record the data with, instead of the current time. Staleness is measured from it. | diff --git a/docs/framework/vue/reference/type-aliases/AnyDataTag.md b/docs/framework/vue/reference/type-aliases/AnyDataTag.md index 4880a33035d..67b55562067 100644 --- a/docs/framework/vue/reference/type-aliases/AnyDataTag.md +++ b/docs/framework/vue/reference/type-aliases/AnyDataTag.md @@ -13,7 +13,7 @@ Matches any type that has been tagged with [DataTag](DataTag.md), whatever its d ## Properties -| Property | Type | -| ------ | ------ | -| `[dataTagErrorSymbol]` | `any` | -| `[dataTagSymbol]` | `any` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `[dataTagErrorSymbol]` | `any` | The error type the key was tagged with. | +| `[dataTagSymbol]` | `any` | The data type the key was tagged with. | diff --git a/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md b/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md index 9f4798c3729..d90605783fb 100644 --- a/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md +++ b/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md @@ -7,15 +7,15 @@ title: MutationFunctionContext type MutationFunctionContext = object; ``` -Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) +Defined in: [packages/query-core/src/types.ts:1849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1849) The object passed to `mutationFn` and the mutation callbacks: the `QueryClient`, the mutation's `meta`, and its `mutationKey`. ## Properties -| Property | Type | -| ------ | ------ | -| `client` | `QueryClient` | -| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | -| `mutationKey?` | [`MutationKey`](MutationKey.md) | +| Property | Type | Description | +| ------ | ------ | ------ | +| `client` | `QueryClient` | The `QueryClient` the mutation runs in. | +| `meta` | [`MutationMeta`](MutationMeta.md) \| `undefined` | The `meta` of the mutation options. | +| `mutationKey?` | [`MutationKey`](MutationKey.md) | The `mutationKey` of the mutation options, if set. | diff --git a/docs/framework/vue/reference/type-aliases/MutationScope.md b/docs/framework/vue/reference/type-aliases/MutationScope.md index 942e27a5de3..52abe2077a6 100644 --- a/docs/framework/vue/reference/type-aliases/MutationScope.md +++ b/docs/framework/vue/reference/type-aliases/MutationScope.md @@ -7,7 +7,7 @@ title: MutationScope type MutationScope = object; ``` -Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) +Defined in: [packages/query-core/src/types.ts:1826](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1826) Groups mutations so they run one after another instead of in parallel. Mutations that share the same `id` form a queue: while one is running, the others wait in `isPaused: true` @@ -15,6 +15,6 @@ state and resume automatically when their turn comes. Mutations with no scope al ## Properties -| Property | Type | -| ------ | ------ | -| `id` | `string` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `id` | `string` | The scope's identifier. Mutations with the same `id` run one after another. | diff --git a/docs/framework/vue/reference/type-aliases/MutationStateOptions.md b/docs/framework/vue/reference/type-aliases/MutationStateOptions.md index 6c70ac4b1f3..3ae9f510c8e 100644 --- a/docs/framework/vue/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/vue/reference/type-aliases/MutationStateOptions.md @@ -24,7 +24,7 @@ one (to its state, by default). ## Properties -| Property | Type | -| ------ | ------ | -| `filters?` | `VueMutationFilters` | -| `select?` | (`mutation`: `TMutation`) => `TResult` | +| Property | Type | Description | +| ------ | ------ | ------ | +| `filters?` | `VueMutationFilters` | The filters that select the mutations to return the state of. | +| `select?` | (`mutation`: `TMutation`) => `TResult` | Maps each matching mutation to the value returned for it. Defaults to the mutation's `state`. | diff --git a/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md index a8bbd7d476d..c5f52cdffb2 100644 --- a/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md +++ b/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md @@ -7,7 +7,7 @@ title: QueryKeyWithDataTag type QueryKeyWithDataTag = object; ``` -Defined in: [packages/query-core/src/types.ts:145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L145) +Defined in: [packages/query-core/src/types.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L151) An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the options returned by `queryOptions`. @@ -28,6 +28,6 @@ An object whose `queryKey` is tagged with [DataTag](DataTag.md), like the option ## Properties -| Property | Type | -| ------ | ------ | -| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | +| Property | Type | Description | +| ------ | ------ | ------ | +| `queryKey` | [`DataTag`](DataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> | The query key, tagged with the query's data and error types. | diff --git a/docs/framework/vue/reference/type-aliases/TimeoutProvider.md b/docs/framework/vue/reference/type-aliases/TimeoutProvider.md index 2ba02bd2c27..3f2ceb14d2a 100644 --- a/docs/framework/vue/reference/type-aliases/TimeoutProvider.md +++ b/docs/framework/vue/reference/type-aliases/TimeoutProvider.md @@ -25,9 +25,9 @@ also support delays longer than the ~24-day maximum of the global `setTimeout`. ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | -| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | -| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | -| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `clearInterval` | `readonly` | (`intervalId`: `TTimerId` \| `undefined`) => `void` | Cancels an interval scheduled with `setInterval`. | +| `clearTimeout` | `readonly` | (`timeoutId`: `TTimerId` \| `undefined`) => `void` | Cancels a timeout scheduled with `setTimeout`. | +| `setInterval` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run every `delay` milliseconds, like the global `setInterval`. | +| `setTimeout` | `readonly` | (`callback`: [`TimeoutCallback`](TimeoutCallback.md), `delay`: `number`) => `TTimerId` | Schedules `callback` to run once after `delay` milliseconds, like the global `setTimeout`. |