Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(react-query): backport v5 apis about infinite query #9334

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

Open
manudeli wants to merge 9 commits into TanStack:v4
base: v4
Choose a base branch
Loading
from manudeli:react-query/backport-infinite-query

Conversation

Copy link
Collaborator

@manudeli manudeli commented Jun 29, 2025
edited
Loading

New Features and Utilities:

  • Added infiniteQueryOptions
  • Added useSuspenseInfiniteQuery
  • Added type DefinedInitialDataInfiniteOptions, type UndefinedInitialDataInfiniteOptions
  • Added function overload for useInfiniteQuery to return DefinedUseInfiniteQueryResult when using infiniteData

Deprecations:

  • Marked several overloads of useInfiniteQuery as deprecated, with a note that they will be removed in the next major version. (packages/react-query/src/useInfiniteQuery.ts)

WooWan and gwansikk reacted with thumbs up emoji WooWan and gwansikk reacted with heart emoji WooWan and gwansikk reacted with rocket emoji
@manudeli manudeli self-assigned this Jun 29, 2025
Copy link

nx-cloud bot commented Jun 29, 2025
edited
Loading

View your CI Pipeline Execution ↗ for commit c2da2a2

Command Status Duration Result
nx affected --targets=test:lib,test:types,test:... ⛔ Cancelled 3h 5m 35s View ↗
nx affected --targets=test:lib --base=eee4405f7... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025年08月24日 13:01:57 UTC

Copilot

This comment was marked as outdated.

@manudeli manudeli requested a review from Copilot July 16, 2025 09:25
Copilot

This comment was marked as outdated.

@manudeli manudeli requested a review from Copilot July 16, 2025 09:35
Copilot

This comment was marked as outdated.

@manudeli manudeli force-pushed the react-query/backport-infinite-query branch from 91170ba to 89fb2fb Compare July 29, 2025 15:33
@manudeli manudeli requested a review from Copilot July 29, 2025 15:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR backports infinite query APIs from React Query v5 to provide enhanced infinite query functionality and improve API consistency.

  • Added useSuspenseInfiniteQuery hook for suspense-based infinite queries with automatic error boundaries
  • Added infiniteQueryOptions function for creating type-safe infinite query configurations
  • Deprecated multiple function overloads in useQuery and useInfiniteQuery with 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 ProhibitedInfiniteQueryOptionsKeyInV5 is inconsistent with the similar type in queryOptions.ts which is named ProhibitedQueryOptionsKeyInV5. Consider renaming to ProhibitedQueryOptionsKeyInV5 for consistency.
 'useErrorBoundary' | 'suspense'

DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
OmitKeyof<
DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
ProhibitedQueryOptionsKeyInV5
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The type ProhibitedQueryOptionsKeyInV5 is referenced but not defined in this file. This will cause a TypeScript compilation error.

Copilot uses AI. Check for mistakes.

UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
OmitKeyof<
UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
ProhibitedQueryOptionsKeyInV5
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The type ProhibitedQueryOptionsKeyInV5 is referenced but not defined in this file. This will cause a TypeScript compilation error.

Copilot uses AI. Check for mistakes.

Copy link

codesandbox-ci bot commented Jul 29, 2025
edited
Loading

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 9aaf337:

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 marked this pull request as ready for review July 29, 2025 15:46
@manudeli manudeli requested a review from TkDodo July 29, 2025 15:59
- Added `infiniteQueryOptions` function to manage infinite query configurations.
- Implemented `useSuspenseInfiniteQuery` hook for handling infinite queries with suspense.
- Updated types to include `DefinedUseInfiniteQueryResult` and `UseSuspenseInfiniteQueryResult`.
- Marked deprecated overloads in `useQuery` and `useInfiniteQuery` for future removal.
- Added tests for new infinite query options and suspense functionality.
@manudeli manudeli force-pushed the react-query/backport-infinite-query branch from 15a9bcf to 9aaf337 Compare July 29, 2025 16:09
...BaseQuery
- Replaced the implementation of `useSuspenseInfiniteQuery` to use `useBaseQuery` instead of `useInfiniteQuery`.
- Updated return type to reflect the new usage of `InfiniteQueryObserverSuccessResult`.
Copy link
Collaborator Author

@manudeli manudeli left a comment
edited
Loading

Choose a reason for hiding this comment

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

@TkDodo I left comments with my intentions

Comment on lines +19 to +37
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>
Copy link
Collaborator Author

@manudeli manudeli Jul 29, 2025
edited
Loading

Choose a reason for hiding this comment

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

Another function overload that returns DefinedUseInfiniteQueryResult is added when using initialData.

@tanstack/react-query v5 also support this

Comment on lines +124 to +135
export type DefinedUseInfiniteQueryResult<
TData = unknown,
TError = unknown,
> = DefinedInfiniteQueryObserverResult<TData, TError>

export type UseSuspenseInfiniteQueryResult<
TData = unknown,
TError = unknown,
> = OmitKeyof<
DefinedInfiniteQueryObserverResult<TData, TError>,
'isPlaceholderData'
>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new types

@@ -24,6 +49,7 @@ export function useInfiniteQuery<
TQueryKey
>,
): UseInfiniteQueryResult<TData, TError>
/** @deprecated This function overload will be removed in the next major version. */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mark some useInfiniteQuery's function overloads as deprecated

Copy link

coderabbitai bot commented Aug 24, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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 skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@manudeli manudeli force-pushed the react-query/backport-infinite-query branch from c239705 to 16c08c1 Compare August 24, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

Copilot code review Copilot Copilot left review comments

@TkDodo TkDodo Awaiting requested review from TkDodo

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /