Skip to content

docs: enhance docs/server/non-json-content-types page - #6780

Merged
KATT merged 13 commits into
trpc:mainfrom
tresorama:docs/update-non-json-data-page
May 26, 2025
Merged

KATT merged 13 commits into
trpc:mainfrom
tresorama:docs/update-non-json-data-page

Conversation

@tresorama

@tresorama tresorama commented May 24, 2025 •

Copy link
Copy Markdown
Contributor

🎯 Changes

  • add server section title as ##/h2, and changed sub sections to ###/h3
  • add a tip for helping user fix potential body parsing errors
  • add a guide on how to fix typescript error when using splitLink and server uses transformer
  • fix server procedure examples that was using query, now they use mutation
  • better indentation for readability

✅ 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

  • Documentation
    • Expanded guidance on configuring tRPC clients to handle non-JSON content types, including detailed examples for binary data and custom transformers.
    • Clarified server-side request parsing for different content types and provided best practices for middleware usage.
    • Updated code samples to use mutations for form and binary data submissions, and added new explanations for handling file and binary inputs.

@coderabbitai

coderabbitai Bot commented May 24, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The documentation is updated to provide comprehensive examples and explanations for supporting non-JSON serializable content types in tRPC. It covers client transformer configuration, server-side request body parsing, and handling of binary data inputs, including changes to example procedure signatures and the addition of new explanatory sections.

Changes

File(s) Change Summary
www/docs/server/non-json-content-types.md Expanded documentation with examples for client transformer setup, server parsing, binary input handling, and updated method signatures from query to mutation for relevant procedures.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant tRPC_Server
    participant Middleware

    Client->>tRPC_Server: Send request (with FormData or binary input)
    tRPC_Server->>Middleware: Check Content-Type, selectively apply body parser
    Middleware-->>tRPC_Server: Parsed input (FormData, binary, etc.)
    tRPC_Server->>tRPC_Server: Route to mutation procedure (handles FormData or binary)
    tRPC_Server-->>Client: Response
Loading

Possibly related PRs

Suggested labels

♻️ autoupdate

Poem

In the docs, a new path we hop,
With FormData and files that never stop.
Transformers and parsers, all set to go,
For binary streams and data flow.
Now tRPC handles more than JSON delight,
🐇—hopping forward, making devs’ futures bright!


🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in 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

vercel Bot commented May 24, 2025 •

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 1:18pm

@vercel

vercel Bot commented May 24, 2025

Copy link
Copy Markdown

@tresorama is attempting to deploy a commit to the trpc Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented May 24, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

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

@trpc/react-query

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

@trpc/next

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

@trpc/server

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

@trpc/tanstack-react-query

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

@trpc/upgrade

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

commit: 746dc72

@KATT
KATT marked this pull request as ready for review May 26, 2025 13:13
@KATT
KATT requested a review from a team as a code owner May 26, 2025 13:13
@KATT KATT changed the title docs: enchance docs/server/non-json-content-types page docs: enhance docs/server/non-json-content-types page May 26, 2025
@KATT
KATT enabled auto-merge (squash) May 26, 2025 13:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
www/docs/server/non-json-content-types.md (1)

55-57: Refine TypeScript capitalization and clarity.

  • Capitalize “TypeScript” instead of “typescript” for consistency.
  • Rephrase “your tRPC client link defines transformer” to something like “your tRPC client link configuration includes the same transformer used by the server.”
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95d1997 and b6475ea.

📒 Files selected for processing (1)
  • www/docs/server/non-json-content-types.md (4 hunks)
🔇 Additional comments (2)
www/docs/server/non-json-content-types.md (2)

128-128: Use .mutation() for FormData-based procedures.

Switching from .query(...) to .mutation(...) correctly reflects that FormData operations generally have side effects. This update is appropriate.


155-155: Use .mutation() for binary/file uploads.

Changing the upload procedure to .mutation(...) aligns with side-effectful operations (file uploads). This looks good.

Comment on lines +81 to +83
url,
transformers: superjson, // or your other transformer
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix property name for the batch link transformer.

The httpBatchLink option should be transformer (singular), not transformers. With the wrong key, your transformer will be ignored.

Apply this diff:

 false: httpBatchLink({
   url,
-  transformers: superjson, // or your other transformer
+  transformer: superjson, // or your other transformer
 }),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
url,
transformers: superjson, // or your other transformer
}),
url,
transformer: superjson, // or your other transformer
}),
🤖 Prompt for AI Agents
In www/docs/server/non-json-content-types.md at lines 81 to 83, the property
name for specifying the transformer in the httpBatchLink options is incorrectly
written as `transformers`. It should be `transformer` (singular). Change the
property name from `transformers` to `transformer` to ensure the transformer is
correctly applied and not ignored.

@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 May 27, 2025

This branch was successfully deployed

2 active deployments
Preview – www — 746dc72b Deployed May 26, 2025 by vercel[bot]
Preview – trpc-next-app-dir — 746dc72b Deployed May 26, 2025 by vercel[bot]
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