Skip to content

Conversation

@Nick-Lucas
Copy link
Contributor

@Nick-Lucas Nick-Lucas commented Feb 19, 2025

Closes #

  • Add pathKey and pathFilter so that routes and single procedures can be invalidated entirely and with a nicer interface (no input needed)
  • Add infiniteQueryKey and infiniteQueryFilter
  • Make infinite methods only appear when there's a cursor
  • Adds a useTRPCClient hook to get the typed vanilla client
  • Fixes skipToken not working
  • Fixes types for infiniteQueryOptions
  • Revamps testing for codemod to include more granular snapshot testing and also run spec files against the before/after

🎯 Changes

What changes are made in this PR? Is it a feature or a bug fix?

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

Summary by CodeRabbit

  • New Features

    • Introduced a new hook for accessing client functionality directly.
    • Added improved support for infinite queries and optimistic updates, providing smoother data-fetching experiences.
    • Enhanced query invalidation methods for better cache management.
    • Added new methods for handling path-based queries and filters.
  • Refactor

    • Standardized core API method names to better align with routing concepts.
    • Enhanced context management for clearer separation between client access and utility operations.
  • Documentation

    • Updated usage guides and migration instructions to reflect the new hooks and API changes.
    • Clarified documentation on new filtering capabilities and query management.
  • Tests

    • Expanded testing coverage to validate suspense queries, cache invalidation, and skip token behaviors.
    • Introduced new tests for optimistic updates and improved handling of query options.
    • Added tests for the new routing functionalities and query filter methods.

@railway-app
Copy link

railway-app bot commented Feb 19, 2025

This PR was not deployed automatically as @Nick-Lucas does not have access to the Railway project.

In order to get automatic PR deploys, please add @Nick-Lucas to the project inside the project settings page.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2025

Walkthrough

The changes span multiple files across the tanstack-react-query package and its upgrade module. Key updates include renaming the exported type DecorateQueryKeyable to DecorateRouterKeyable and modifying method names (e.g. queryKeypathKey, queryFilterpathFilter). Enhancements for infinite queries were introduced with new interfaces and methods, while utility functions such as getQueryKeyInternal now accept optional parameters. Additionally, the React context was refined by adding a useTRPCClient hook and documentation was updated. Several test cases and migration scripts were also added or updated.

Changes

File(s) Change Summary
packages/tanstack-react-query/src/index.ts
packages/tanstack-react-query/src/internals/createOptionsProxy.ts
packages/tanstack-react-query/src/internals/types.ts
Renamed DecorateQueryKeyable to DecorateRouterKeyable; updated method names from queryKey/queryFilter to pathKey/pathFilter; added new interface DecorateInfiniteQueryProcedure and new types (WithRequired, CursorInput, OptionalCursorInput); updated procedure utils.
packages/tanstack-react-query/src/internals/utils.ts
packages/tanstack-react-query/src/internals/infiniteQueryOptions.ts
packages/tanstack-react-query/src/internals/queryOptions.ts
packages/tanstack-react-query/src/internals/Context.tsx
Made parameters in getQueryKeyInternal optional; added an input parameter to query options functions; updated the TRPC context to use TRPCClient<TRouter> and added the useTRPCClient hook.
Various test files in packages/tanstack-react-query/test/ and packages/upgrade/test/__fixtures__/hooks/ Added new test cases for infinite queries, suspense handling, optimistic updates, query invalidation, and React context; updated tests to reflect the renaming of query methods and enhancements in cache invalidation logic.
www/docs/client/tanstack-react-query/usage.mdx
www/docs/client/tanstack-react-query/setup.mdx
www/docs/client/tanstack-react-query/migrating.mdx
www/blog/2025-02-17-new-tanstack-react-query-integration.mdx
packages/upgrade/README.md
packages/upgrade/tsconfig.json
packages/upgrade/vitest.config.ts
Updated documentation and migration guides to reflect API renaming and the introduction of the new useTRPCClient hook; enhanced setup instructions and configuration files with additional dependency and compiler option updates.
packages/upgrade/src/transforms/hooksToOptions.ts
packages/upgrade/package.json
packages/upgrade/test/transforms.test.ts
packages/upgrade/src/bin/index.ts
packages/upgrade/src/lib/scanners.ts
packages/upgrade/src/lib/git.ts
packages/upgrade/src/lib/pkgmgr.ts
Restructured the transformation logic for utility methods; updated environment variable access from dot to bracket notation; introduced new dependencies and updated package configurations.
Various files under packages/upgrade/test/__fixtures__/hooks/ (e.g. withInvalidate, utilities, optimistic-update, etc.) Enhanced cache invalidation processes and utility functions; added new components and test cases that demonstrate advanced query handling and invalidation via multiple TRPC and React Query utilities.

Sequence Diagram(s)

sequenceDiagram
  participant Component as React Component
  participant TRPCProvider as TRPCProvider
  participant ClientContext as TRPCClientContext
  Component->>TRPCProvider: Render within Provider
  TRPCProvider->>ClientContext: Provide TRPC Client instance
  Component->>ClientContext: Invoke useTRPCClient()
  ClientContext-->>Component: Return TRPC client instance
Loading
sequenceDiagram
  participant Component as React Component
  participant Mutation as useMutation
  participant QueryClient as React Query Client
  Component->>Mutation: Trigger mutation (onMutate)
  Mutation->>QueryClient: Cancel queries & apply optimistic update
  alt Mutation Fails
    Mutation->>QueryClient: onError restores previous state
  else Mutation Succeeds
    Mutation->>QueryClient: onSettled invalidates queries
  end
Loading

Possibly related PRs

  • Add missing imports to docs for server-components #6545 – The changes in the main PR, specifically the renaming of the DecorateQueryKeyable type to DecorateRouterKeyable, are directly related to the modifications in the retrieved PR, which also involves updating the usage of query-related methods to align with the new naming conventions. Both PRs reflect a shift towards a more consistent and routing-focused API.
  • chore(server): simplify callProcedure & undeprecated .createCaller() #6472 – The changes in the main PR, specifically the renaming of the DecorateQueryKeyable type to DecorateRouterKeyable, are directly related to the modifications in the retrieved PR where the callProcedure function's parameter handling has been simplified to pass the router directly, indicating a broader shift towards a more consistent naming and usage pattern across the codebase.
  • chore: bump tanstack packages #6479 – The changes in the main PR, specifically the renaming of the DecorateQueryKeyable type to DecorateRouterKeyable, are directly related to the modifications in the retrieved PR, which involve updates to the @tanstack/react-query package that likely include similar type changes. Thus, both PRs are connected through the updates in type definitions and their usage in the context of the TanStack library.

Suggested labels

♻️ autoupdate

Suggested reviewers

  • KATT

Poem

I'm a little rabbit with a curious mind,
Hopping through the code, where changes you will find.
Keys are now paths and queries redefined,
With infinite dreams and hooks perfectly aligned.
I celebrate with a hop and a joyful little rhyme,
In a garden of updates, coding in springtime!
🐇✨

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0c90cf and 4f0538d.

📒 Files selected for processing (1)
  • vitest.config.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: E2E-tests (tanstack-start)
  • GitHub Check: E2E-tests (next-prisma-websockets-starter)
  • GitHub Check: E2E-tests (next-prisma-todomvc)
  • GitHub Check: E2E-tests (next-prisma-starter)
  • GitHub Check: E2E-tests (minimal-react)
  • GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
  • GitHub Check: E2E-tests (express-minimal)
  • GitHub Check: E2E-tests (.test/ssg)
  • GitHub Check: E2E-tests (.experimental/next-app-dir)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
  • GitHub Check: E2E-tests (Bun) (bun, ubuntu-latest)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
  • GitHub Check: E2E-tests (Deno) (deno-deploy)
  • GitHub Check: test
🔇 Additional comments (1)
vitest.config.ts (1)

66-66: Adding retry for test robustness.

Adding a retry option is a good approach for handling potentially flaky tests, especially for asynchronous operations common in React Query. This will help improve CI reliability while maintaining test coverage.

Consider adding a comment explaining why retries are necessary, particularly if certain test suites (like those for infinite queries or the new tests mentioned in the PR) are known to be occasionally unstable.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@vercel
Copy link

vercel bot commented Feb 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview Feb 26, 2025 5:55pm
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 5:55pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
www ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 5:55pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2025

Open in Stackblitz

@trpc/client

npm i https://pkg.pr.new/trpc/trpc/@trpc/client@6529

@trpc/next

npm i https://pkg.pr.new/trpc/trpc/@trpc/next@6529

@trpc/react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/react-query@6529

@trpc/server

npm i https://pkg.pr.new/trpc/trpc/@trpc/server@6529

@trpc/tanstack-react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/tanstack-react-query@6529

@trpc/upgrade

npm i https://pkg.pr.new/trpc/trpc/@trpc/upgrade@6529

commit: 4f0538d

@Nick-Lucas Nick-Lucas changed the title Infinite-query-keys Improvements to methods in Tanstack React Query package Feb 19, 2025
@zbeyens
Copy link

zbeyens commented Feb 19, 2025

Looking for this PR! My usage of queryClient.getQueryData(trpc.chat.chat.queryKey({ id: chatId })) is currently returning undefined since it's missing the query type.

juliusmarminge
juliusmarminge previously approved these changes Feb 26, 2025
Copy link
Member

@juliusmarminge juliusmarminge left a comment

Choose a reason for hiding this comment

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

Feel free to revert my last commit

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/tanstack-react-query/src/internals/types.ts (1)

21-25: Consider using undefined instead of void in union types.

The static analysis tool correctly flags that using void in a union type can be confusing. While functionally similar in this context, using undefined is more conventional and semantically clearer.

Apply this diff to address the lint warning:

/**
 * @remark `void` is here due to https://github.com/trpc/trpc/pull/4374
 */
type CursorInput = { cursor?: any };
-export type OptionalCursorInput = CursorInput | void;
+export type OptionalCursorInput = CursorInput | undefined;
🧰 Tools
🪛 Biome (1.9.4)

[error] 25-25: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bda9a9f and 724b15f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/tanstack-react-query/src/internals/createOptionsProxy.ts (10 hunks)
  • packages/tanstack-react-query/src/internals/types.ts (2 hunks)
  • packages/tanstack-react-query/test/queryKeyable.test.tsx (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/tanstack-react-query/test/queryKeyable.test.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
packages/tanstack-react-query/src/internals/types.ts

[error] 25-25: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: E2E-tests (vercel-edge-runtime)
  • GitHub Check: E2E-tests (tanstack-start)
  • GitHub Check: E2E-tests (standalone-server)
  • GitHub Check: E2E-tests (soa)
  • GitHub Check: E2E-tests (next-prisma-websockets-starter)
  • GitHub Check: E2E-tests (next-prisma-todomvc)
  • GitHub Check: E2E-tests (next-prisma-starter)
  • GitHub Check: E2E-tests (next-minimal-starter)
  • GitHub Check: E2E-tests (next-formdata)
  • GitHub Check: E2E-tests (minimal-react)
  • GitHub Check: E2E-tests (fastify-server)
  • GitHub Check: E2E-tests (express-server)
  • GitHub Check: E2E-tests (express-minimal)
  • GitHub Check: E2E-tests (cloudflare-workers)
  • GitHub Check: E2E-tests (.test/ssg)
  • GitHub Check: E2E-tests (.test/internal-types-export)
  • GitHub Check: E2E-tests (.test/diagnostics-big-router)
  • GitHub Check: E2E-tests (.experimental/next-app-dir)
  • GitHub Check: test
  • GitHub Check: Lint and auto-fix
🔇 Additional comments (8)
packages/tanstack-react-query/src/internals/types.ts (2)

7-9: Great addition of the WithRequired utility type.

This utility type is a valuable addition that enforces required properties in object types, enhancing type safety throughout the codebase. It's correctly implemented using mapped types.


30-32: Clean refactoring of the ExtractCursorType type.

This change improves code organization by reusing the CursorInput type rather than repeating the same structure, making the code more maintainable.

packages/tanstack-react-query/src/internals/createOptionsProxy.ts (6)

48-69: Good renaming from DecorateQueryKeyable to DecorateRouterKeyable.

The interface rename and method changes (queryKeypathKey, queryFilterpathFilter) align better with their purpose of working with router paths. The documentation updates clearly explain the functionality and provide relevant links to official documentation.


96-151: Well-structured DecorateInfiniteQueryProcedure interface.

This new interface adds proper support for infinite queries with well-documented methods that align with the PR objectives. The implementation is type-safe and comprehensive, covering query keys, options, and filters specifically for infinite queries.


152-196: Good extension of DecorateQueryProcedure from DecorateRouterKeyable.

This change correctly establishes the inheritance relationship between query procedures and router keyable functionality, improving the overall type hierarchy and preventing code duplication.


228-231: Smart conditional type for infinite query procedures.

The conditional inclusion of DecorateInfiniteQueryProcedure based on whether the input extends OptionalCursorInput elegantly handles the requirement mentioned in the PR objectives of making infinite methods only appear when a cursor is present.


346-354: Simplified implementation of path-related methods.

The pathKey implementation now correctly calls getQueryKeyInternal with just the path parameter, addressing the PR objective of supporting getQueryKeyInternal without needing second and third parameters for route methods.


386-394: Good implementation of infinite query methods.

The new methods for infinite queries are well implemented, properly using the internal utilities and maintaining consistency with the existing query methods. These changes directly address the PR objectives of adding infiniteQueryKey and infiniteQueryFilter.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 724b15f and f0c90cf.

📒 Files selected for processing (1)
  • packages/tanstack-react-query/src/internals/createOptionsProxy.ts (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: E2E-tests (vercel-edge-runtime)
  • GitHub Check: E2E-tests (tanstack-start)
  • GitHub Check: E2E-tests (standalone-server)
  • GitHub Check: E2E-tests (soa)
  • GitHub Check: E2E-tests (next-prisma-websockets-starter)
  • GitHub Check: E2E-tests (next-prisma-todomvc)
  • GitHub Check: E2E-tests (next-prisma-starter)
  • GitHub Check: E2E-tests (next-minimal-starter)
  • GitHub Check: E2E-tests (next-formdata)
  • GitHub Check: E2E-tests (minimal-react)
  • GitHub Check: E2E-tests (fastify-server)
  • GitHub Check: E2E-tests (express-server)
  • GitHub Check: E2E-tests (express-minimal)
  • GitHub Check: E2E-tests (cloudflare-workers)
  • GitHub Check: E2E-tests (.test/ssg)
  • GitHub Check: E2E-tests (.test/internal-types-export)
  • GitHub Check: E2E-tests (.test/diagnostics-big-router)
  • GitHub Check: E2E-tests (.experimental/next-app-dir)
  • GitHub Check: test
🔇 Additional comments (6)
packages/tanstack-react-query/src/internals/createOptionsProxy.ts (6)

96-151: Good addition: New interface for infinite query procedures

Adding the DecorateInfiniteQueryProcedure interface with dedicated methods for infinite queries improves type safety and makes it clearer when and how to use infinite queries.

The JSDoc comments are thorough and include links to relevant documentation, which is excellent for developer experience.


229-231: Fixed lint issue: Using Record<string, never> instead of {}

You've correctly replaced {} with Record<string, never> as recommended in previous reviews to address the lint warning about using empty object types.


346-354: Functionality improvement: Simplified path key methods

The implementation of pathKey now uses getQueryKeyInternal with fewer parameters, making it easier to invalidate all queries for a route without needing input parameters.

This aligns with the PR objective to "allow for the complete invalidation of routes and single procedures without requiring input."


386-394: New feature: Added infinite query key and filter methods

The addition of infiniteQueryKey and infiniteQueryFilter methods provides dedicated support for infinite queries, making them first-class citizens in the API.

This implementation matches the PR objective to "introduce infiniteQueryKey and infiniteQueryFilter."


263-267:

Details

❓ Verification inconclusive

Ensure backward compatibility

With the transition from query-based to router/path-based terminology in the API, ensure that sufficient deprecation notices and migration paths are provided for users upgrading from previous versions.

Consider adding temporary backwards compatibility shims if this is a breaking change.


🏁 Script executed:

#!/bin/bash
# Check for any migrations or upgrade scripts
fd "upgrade|migration" --type f packages/

# Check if there are any re-export patterns that might provide backwards compatibility
rg -A 5 -B 5 "export.*DecorateQueryKeyable|export.*type.*=.*DecorateRouterKeyable" packages/

Length of output: 138


Backward Compatibility Verification Needed

The transition from query-based to router/path-based terminology is clear, but the automated checks for upgrade or migration scripts and re-export patterns did not reveal the existence of deprecation notices or backward compatibility shims. Please manually verify that:

  • Sufficient deprecation warnings and migration guides are provided to support users upgrading from previous versions.
  • Temporary backward compatibility shims or re-export patterns are implemented where necessary to bridge the terminology change.

This verification is essential to ensure that users are well-informed and that the migration path is smooth.


241-260:

Details

❓ Verification inconclusive

API renaming: DecoratedRouterRecord

Renaming DecoratedProcedureUtilsRecord to DecoratedRouterRecord maintains consistency with the other interface renamings in this PR.

Ensure this rename is documented in any migration guides.


🏁 Script executed:

#!/bin/bash
# Check if this type is exported and used in other files that might need updating
rg "DecoratedProcedureUtilsRecord|DecoratedRouterRecord" packages/ --type ts

Length of output: 78


Manual Verification Required: Update Migration Documentation for DecoratedRouterRecord

  • The renaming from DecoratedProcedureUtilsRecord to DecoratedRouterRecord has been implemented for API consistency.
  • The automated grep search in the packages/ directory did not return any additional references. However, please manually verify that:
    • Any usage of the old name in migration guides and external documentation is updated.
    • The exported type in packages/tanstack-react-query/src/internals/createOptionsProxy.ts is consistent with upstream dependencies.

Comment on lines +48 to +69
export interface DecorateRouterKeyable {
/**
* Calculate the TanStack Query Key for a Route
* Calculate the TanStack Query Key for any path, could be used to invalidate every procedure beneath this path
*
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
*/
queryKey: () => TRPCQueryKey;
pathKey: () => TRPCQueryKey;

/**
* Calculate a TanStack Query Filter for a Route
* Calculate a TanStack Query Filter for any path, could be used to manipulate every procedure beneath this path
*
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
*/
queryFilter: (input?: undefined, filters?: QueryFilters) => QueryFilters;
pathFilter: (
filters?: QueryFilters<unknown, unknown, unknown, TRPCQueryKey>,
) => WithRequired<
QueryFilters<unknown, unknown, unknown, TRPCQueryKey>,
'queryKey'
>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

API change: Renamed interface and methods

The interface has been renamed from DecorateQueryKeyable to DecorateRouterKeyable, with methods renamed from queryKey/queryFilter to pathKey/pathFilter. This better represents their purpose for invalidating entire routes rather than specific queries.

Make sure this API change is well-documented in migration guides to help users update their code accordingly.


🏁 Script executed:

#!/bin/bash
# Check if there are upgrade guides or migration docs for these API changes
fd "migration|upgrade" --type f -e md -e mdx packages/

Length of output: 56


API Change Notification: Migration Guide Update Required

The updated code in packages/tanstack-react-query/src/internals/createOptionsProxy.ts now renames the interface from DecorateQueryKeyable to DecorateRouterKeyable and changes the method names from queryKey/queryFilter to pathKey/pathFilter for better clarity regarding route invalidation. However, our search for migration or upgrade guides (using a file search for "migration" or "upgrade" within the packages/ directory) returned no results.

Please add or update the migration documentation to detail these API changes so that users understand how to update their code accordingly. Consider including:

  • A clear explanation of the API renaming.
  • A code diff snippet highlighting the changes.
  • Guidance for users on how to adapt their existing code.

@Nick-Lucas Nick-Lucas merged commit f490f46 into next Feb 26, 2025
41 checks passed
@Nick-Lucas Nick-Lucas deleted the infinite-query-keys branch February 26, 2025 22:03
@coderabbitai coderabbitai bot mentioned this pull request Feb 27, 2025
3 tasks
@github-actions
Copy link
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2025
@KATT KATT restored the infinite-query-keys branch March 1, 2025 11:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants