feat(react-query): backport v5 apis about infinite query#9334
feat(react-query): backport v5 apis about infinite query#9334manudeli merged 2 commits intoTanStack:v4from
Conversation
|
View your CI Pipeline Execution ↗ for commit 32d3516
☁️ Nx Cloud last updated this comment at |
5b39d68 to
8e281a9
Compare
91170ba to
89fb2fb
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR backports infinite query APIs from React Query v5 to provide enhanced infinite query functionality and improve API consistency.
- Added
useSuspenseInfiniteQueryhook for suspense-based infinite queries with automatic error boundaries - Added
infiniteQueryOptionsfunction for creating type-safe infinite query configurations - Deprecated multiple function overloads in
useQueryanduseInfiniteQuerywith improved deprecation messages
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-query/src/useSuspenseInfiniteQuery.ts | New suspense-based infinite query hook implementation |
| packages/react-query/src/infiniteQueryOptions.ts | New infinite query options factory function with type definitions |
| packages/react-query/src/types.ts | Added new result types for suspense and defined infinite queries |
| packages/react-query/src/useQuery.ts | Enhanced deprecation messages for function overloads |
| packages/react-query/src/useInfiniteQuery.ts | Added new overload and enhanced deprecation messages |
| packages/react-query/src/queryOptions.ts | Updated to omit prohibited v5 keys from options |
| packages/react-query/src/index.ts | Exported new functions and types |
| packages/react-query/src/tests/* | Comprehensive type and unit tests for new functionality |
| packages/query-core/src/types.ts | Cleaned up deprecated comment formatting |
| packages/query-core/src/queryClient.ts | Cleaned up deprecated comment formatting |
| packages/query-core/src/queryCache.ts | Cleaned up deprecated comment formatting |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/react-query/src/infiniteQueryOptions.ts:22
- The type name
ProhibitedInfiniteQueryOptionsKeyInV5is inconsistent with the similar type inqueryOptions.tswhich is namedProhibitedQueryOptionsKeyInV5. Consider renaming toProhibitedQueryOptionsKeyInV5for consistency.
'useErrorBoundary' | 'suspense'
| DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, | ||
| OmitKeyof< | ||
| DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, | ||
| ProhibitedQueryOptionsKeyInV5 |
There was a problem hiding this comment.
The type ProhibitedQueryOptionsKeyInV5 is referenced but not defined in this file. This will cause a TypeScript compilation error.
| UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, | ||
| OmitKeyof< | ||
| UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, | ||
| ProhibitedQueryOptionsKeyInV5 |
There was a problem hiding this comment.
The type ProhibitedQueryOptionsKeyInV5 is referenced but not defined in this file. This will cause a TypeScript compilation error.
|
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 32d3516:
|
15a9bcf to
9aaf337
Compare
| export function useInfiniteQuery< | ||
| TQueryFnData = unknown, | ||
| TError = unknown, | ||
| TData = TQueryFnData, | ||
| TQueryKey extends QueryKey = QueryKey, | ||
| >( | ||
| options: UseInfiniteQueryOptions< | ||
| TQueryFnData, | ||
| TError, | ||
| TData, | ||
| TQueryFnData, | ||
| TQueryKey | ||
| > & { | ||
| initialData: | ||
| | NonUndefinedGuard<InfiniteData<TQueryFnData>> | ||
| | (() => NonUndefinedGuard<InfiniteData<TQueryFnData>>) | ||
| | undefined | ||
| }, | ||
| ): DefinedUseInfiniteQueryResult<TData, TError> |
There was a problem hiding this comment.
Another function overload that returns DefinedUseInfiniteQueryResult is added when using initialData.
@tanstack/react-query v5 also support this
| export type DefinedUseInfiniteQueryResult< | ||
| TData = unknown, | ||
| TError = unknown, | ||
| > = DefinedInfiniteQueryObserverResult<TData, TError> | ||
|
|
||
| export type UseSuspenseInfiniteQueryResult< | ||
| TData = unknown, | ||
| TError = unknown, | ||
| > = OmitKeyof< | ||
| DefinedInfiniteQueryObserverResult<TData, TError>, | ||
| 'isPlaceholderData' | ||
| > |
| TQueryKey | ||
| >, | ||
| ): UseInfiniteQueryResult<TData, TError> | ||
| /** @deprecated This function overload will be removed in the next major version. */ |
There was a problem hiding this comment.
Mark some useInfiniteQuery's function overloads as deprecated
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Comment |
c239705 to
16c08c1
Compare
…ryOptions for enhanced infinite query handling - Added `useSuspenseInfiniteQuery` hook for improved suspense handling with infinite queries. - Introduced `infiniteQueryOptions` function to streamline infinite query option management. - Updated types to include `DefinedInfiniteQueryObserverResult` and related types for better type safety. - Refactored existing query options to accommodate new infinite query features. - Added tests for new functionalities to ensure correctness and type safety.
94085b4 to
ed2a35b
Compare
New Features and Utilities:
infiniteQueryOptionsuseSuspenseInfiniteQueryDefinedInitialDataInfiniteOptions, typeUndefinedInitialDataInfiniteOptionsuseInfiniteQueryto returnDefinedUseInfiniteQueryResultwhen usinginfiniteDataDeprecations:
useInfiniteQueryas deprecated, with a note that they will be removed in the next major version. (packages/react-query/src/useInfiniteQuery.ts)