Skip to content

feat(query-core, react-query): backport v5 types, deprecate isLoading in favor of isPending in mutation observer results #9266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

manudeli
Copy link
Collaborator

@manudeli manudeli commented Jun 11, 2025

Deprecation and Property to enhance migration to v5 gradually:

  • Marked isLoading property as deprecated in multiple MutationObserver result interfaces (MutationObserverBaseResult, MutationObserverIdleResult, MutationObserverLoadingResult, MutationObserverErrorResult, MutationObserverSuccessResult) and added the isPending property as its replacement.

Type backport like v5:

  • Exported UseSuspenseQueryOptions, UseSuspenseQueryResult, SuspenseQueriesResults, SuspenseQueriesOptions, DefinedInitialDataOptions, and UndefinedInitialDataOptions, DefinedInitialDataOptions and UndefinedInitialDataOptions types like v5
image

Many people are still on v4, and the same is true for my company.
If we backport some of the v5 APIs to v4 well, it would ease their migration and reduce friction. This can help accelerate the adoption of v5 eventually, allowing us to concentrate our efforts on v5 improvements.

What I want to backport after this Pull Request

  1. useSuspenseInfiniteQuery
  2. infiniteQueryOptions

…vor of `isPending` in mutation observer results
Copy link

nx-cloud bot commented Jun 11, 2025

View your CI Pipeline Execution ↗ for commit 569efbb.

Command Status Duration Result
nx affected --targets=test:lib,test:types,test:... ✅ Succeeded 1m 19s View ↗
nx affected --targets=test:lib --base=79f0b9ad2... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-06-11 16:21:32 UTC

Copy link

codesandbox-ci bot commented Jun 11, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 569efbb:

Sandbox Source
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

@manudeli manudeli self-assigned this Jun 11, 2025
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.62%. Comparing base (84e8ae5) to head (569efbb).
Report is 29 commits behind head on v4.

Additional details and impacted files
@@            Coverage Diff             @@
##               v4    #9266      +/-   ##
==========================================
- Coverage   95.16%   91.62%   -3.54%     
==========================================
  Files          13      117     +104     
  Lines         496     4478    +3982     
  Branches      179     1184    +1005     
==========================================
+ Hits          472     4103    +3631     
- Misses         23      344     +321     
- Partials        1       31      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator Author

@manudeli manudeli left a comment

Choose a reason for hiding this comment

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

I left comments with intentions

@@ -136,7 +136,6 @@ export function useQuery<
'queryKey' | 'queryFn'
>,
): UseQueryResult<TData, TError>
/** @deprecated */
export function useQuery<
TQueryFnData,
TError,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This shouldn't be marked as deprecated

Comment on lines +20 to +22
onSuccess: undefined,
onError: undefined,
onSettled: undefined,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

User can't use callbacks(onSuccess, onError, onSettled) not only typescriptly

Comment on lines +672 to 676
/**
* @deprecated This property will be removed in the next major version. Use `isPending` instead.
*/
isLoading: boolean
isPending: boolean
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can now see a strikethrough line on isLoading.

image

Comment on lines 13 to 27
export { useQuery } from './useQuery'
export { useSuspenseQuery } from './useSuspenseQuery'
export { useSuspenseQueries } from './useSuspenseQueries'
export type {
SuspenseQueriesResults,
SuspenseQueriesOptions,
} from './useSuspenseQueries'
export { queryOptions } from './queryOptions'
export type {
DefinedInitialDataOptions,
UndefinedInitialDataOptions,
} from './queryOptions'
export {
defaultContext,
QueryClientProvider,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same order with v5

below is index.ts of @tanstack/react-query v5
image

@manudeli manudeli marked this pull request as ready for review June 11, 2025 13:39
@manudeli manudeli changed the title feat(query-core, react-query): add types, deprecate isLoading in favor of isPending in mutation observer results feat(query-core, react-query): backport v5 types, deprecate isLoading in favor of isPending in mutation observer results Jun 11, 2025
@manudeli
Copy link
Collaborator Author

This resolve this eslint warning
image

@manudeli manudeli merged commit 693a471 into TanStack:v4 Jun 17, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant