Skip to content

chore(server): simplify callProcedure & undeprecated .createCaller()#6472

Merged
KATT merged 6 commits into
nextfrom
02-10-simplify-callProc
Feb 10, 2025
Merged

chore(server): simplify callProcedure & undeprecated .createCaller()#6472
KATT merged 6 commits into
nextfrom
02-10-simplify-callProc

Conversation

@KATT

@KATT KATT commented Feb 10, 2025

Copy link
Copy Markdown
Member

🎯 Changes

  • Undeprecate router.createCaller(), it's practical
  • Simplify callProcedure()-logic by allowing just passing the router in

Summary by CodeRabbit

  • Refactor

    • Streamlined server-side procedure calls by switching to direct router usage for improved consistency and type safety.
    • Updated API signatures and naming conventions, replacing older patterns with clearer, more intuitive alternatives.
  • Documentation

    • Revised server-side call guides to highlight the new caller creation method and provide detailed usage examples.
    • Added deprecation notices for outdated methods and types to assist users transitioning from the previous approach.

@KATT KATT requested review from a team as code owners February 10, 2025 09:34
@coderabbitai

coderabbitai Bot commented Feb 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request updates how tRPC procedures are invoked by replacing references to the router’s internal definition (router._def) with the full router object (router). This change is applied across multiple modules, including server-side rendering helpers, WebSocket adapters, and internal router utilities. Additionally, several exports and types have been deprecated or renamed to promote a more consistent API, and the server-side calls documentation has been updated to reflect these changes.

Changes

File(s) Change Summary
packages/react-query/src/server/ssgProxy.ts
packages/server/src/adapters/ws.ts
packages/server/src/unstable-core-do-not-import/http/contentType.ts
packages/server/src/unstable-core-do-not-import/router.ts
Updated the invocation of callProcedure and getProcedureAtPath functions to pass the entire router object instead of router._def. Function signatures in the router utility have been adjusted for more structured type usage.
packages/server/src/@trpc/server/index.ts Removed export of callProcedure as callTRPCProcedure and deprecated several types (e.g., AnyProcedureAnyTRPCProcedure, AnyRouterAnyTRPCRouter), with guidance for updated naming conventions.
www/docs/server/server-side-calls.md Updated documentation to deprecate router.createCaller() in favor of createCallerFactory(), including new examples and error handling instructions.
www/docs/migration/migrate-from-v10-to-v11.mdx Documented changes for migration from v10 to v11, including updates to callProcedure() parameter structure and new features.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Helper
    participant Router
    participant Procedure

    Client->>Helper: Initiate server-side call
    Helper->>Router: callProcedure(router, params)
    Router->>Procedure: Retrieve and execute procedure
    Procedure-->>Router: Return result
    Router-->>Helper: Pass result
    Helper-->>Client: Return response
Loading

Possibly related PRs

Poem

I’m a bouncy rabbit with a coding delight,
Hopping through routers, making parameters light.
No more _def to weigh me down in code's maze,
A cleaner, brighter path now earns our praise.
With every change, my heart does a skip—🐇💻
CodeRabbit leaps ahead on this revamped trip!


📜 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 0b7cc4d and df60e0c.

📒 Files selected for processing (3)
  • packages/next/src/app-dir/links/nextCache.ts (1 hunks)
  • packages/server/src/unstable-core-do-not-import/router.ts (4 hunks)
  • www/docs/migration/migrate-from-v10-to-v11.mdx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: e2e-legacy-node (next-prisma-todomvc, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
  • GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
  • GitHub Check: Release using pkg.pr.new
  • GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 18.x)
  • GitHub Check: Test a monorepo using built declaration files
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
  • GitHub Check: E2E-tests (Deno) (deno-deploy)
  • GitHub Check: E2E-tests (Bun) (bun, ubuntu-latest)
  • GitHub Check: test
  • GitHub Check: Lint and auto-fix
🔇 Additional comments (5)
packages/next/src/app-dir/links/nextCache.ts (1)

53-53: LGTM!

The change aligns with the PR objectives to simplify callProcedure by passing the full router object instead of its internal definition.

packages/server/src/unstable-core-do-not-import/router.ts (3)

351-355: LGTM!

The change improves type safety by explicitly indicating that the function operates on a router object. The function's logic remains unchanged.


379-386: LGTM!

The change aligns with the PR objectives to simplify callProcedure by accepting a router object instead of its internal definition. The function's error handling logic remains intact.


417-417: LGTM!

The change aligns with the PR objectives by consistently destructuring _def from the router parameter. The function's logic remains unchanged.

www/docs/migration/migrate-from-v10-to-v11.mdx (1)

54-54: LGTM!

The documentation accurately reflects the changes made to the callProcedure function, providing clear guidance for users during migration.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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. (Beta)
  • @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

vercel Bot commented Feb 10, 2025

Copy link
Copy Markdown

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 10, 2025 10:16am
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 10, 2025 10:16am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 10, 2025 10:16am

@railway-app

railway-app Bot commented Feb 10, 2025

Copy link
Copy Markdown

🚅 Previously deployed to Railway in the trpc-sse-and-websockets project. Environment has been deleted.

Comment on lines -117 to -120
:::caution
`router.createCaller()` has been deprecated and will be removed in v11 or v12 of tRPC.
:::

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

cc @trpc/trpc-core fyi

@KATT KATT changed the title chore(server): simplify callProcedure & undeprecated .createCaller() fix(server): lazy load bug, simplify callProcedure, & undeprecated .createCaller() Feb 10, 2025
@KATT KATT changed the title fix(server): lazy load bug, simplify callProcedure, & undeprecated .createCaller() fix(server): simplify callProcedure, & undeprecated .createCaller() Feb 10, 2025
@pkg-pr-new

pkg-pr-new Bot commented Feb 10, 2025

Copy link
Copy Markdown

Open in Stackblitz

npm i https://pkg.pr.new/trpc/trpc/@trpc/client@6472
npm i https://pkg.pr.new/trpc/trpc/@trpc/next@6472
npm i https://pkg.pr.new/trpc/trpc/@trpc/server@6472
npm i https://pkg.pr.new/trpc/trpc/@trpc/react-query@6472

commit: df60e0c

@KATT KATT changed the title fix(server): simplify callProcedure, & undeprecated .createCaller() chore(server): simplify callProcedure, & undeprecated .createCaller() Feb 10, 2025
@KATT KATT enabled auto-merge (squash) February 10, 2025 10:13
@github-actions

Copy link
Copy Markdown
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 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants