Skip to content

Add dedicated non-json inputs page - #6699

Merged
Nick-Lucas merged 7 commits into
mainfrom
formdata-docs
Apr 13, 2025
Merged

Nick-Lucas merged 7 commits into
mainfrom
formdata-docs

Conversation

@Nick-Lucas

@Nick-Lucas Nick-Lucas commented Apr 11, 2025 •

Copy link
Copy Markdown
Contributor

Closes #

🎯 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

  • Documentation
    • Introduced a new guide detailing the handling of non-JSON content types such as FormData, File, and binary inputs.
    • Removed redundant information regarding non-JSON content types from existing documentation.
    • Updated the site navigation to include a link to the new documentation section on non-JSON content types.

@Nick-Lucas
Nick-Lucas requested a review from a team as a code owner April 11, 2025 21:49
@coderabbitai

coderabbitai Bot commented Apr 11, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

A new documentation file has been introduced to explain how tRPC handles non-JSON content types such as FormData, File, and other binary data. In parallel, an existing non-JSON section was removed from another documentation file, and a new sidebar entry was added to link to the new documentation. These changes update and reorganize the information around non-JSON content handling for clarity and improved navigation.

Changes

Files Change Summary
www/docs/.../non-json-content-types.md, www/docs/.../validators.md Added a dedicated doc for non-JSON content types with examples for FormData and binary inputs; removed the previous non-JSON section from the validators documentation.
www/sidebars.ts Updated the sidebar configuration by including a new entry linking to the non-JSON content types documentation.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant T as tRPC Client
    participant HL as HTTP Link
    participant BL as HTTP Batch Link

    C->>T: Initiate procedure call with input
    T->>T: Check input type (Non-JSON vs JSON)
    alt Non-JSON Content
        T->>HL: Route via HTTP Link (native support)
        HL-->>T: Process non-JSON data
    else JSON Content
        T->>BL: Route via HTTP Batch Link (configured)
        BL-->>T: Process JSON data
    end
    T->>C: Return response
Loading

Poem

I'm a rabbit hopping through the docs so light,
New pages appear, shining ever so bright.
Old words removed like leaves in the breeze,
Sidebar now guides with effortless ease.
Code and content make my heart spring,
Happy hops to the changes that the new docs bring!
πŸ₯•πŸ‡

Tip

βš‘πŸ’¬ Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

πŸͺ§ 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 plan to trigger planning for file edits and PR creation.
  • @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.

@railway-app

railway-app Bot commented Apr 11, 2025 •

Copy link
Copy Markdown

πŸš… Deployed to the trpc-pr-6699 environment in trpc-sse-and-websockets

Service Status Web Updated (UTC)
next-prisma-websockets-starter ◻️ Removed (View Logs) Apr 13, 2025 at 12:42 pm
next-sse-chat ◻️ Removed (View Logs) Web Apr 13, 2025 at 12:42 pm

@vercel

vercel Bot commented Apr 11, 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 Apr 13, 2025 9:44am
og-image βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 13, 2025 9:44am
www βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 13, 2025 9:44am

@pkg-pr-new

pkg-pr-new Bot commented Apr 11, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

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

@trpc/next

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

@trpc/react-query

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

@trpc/server

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

@trpc/tanstack-react-query

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

@trpc/upgrade

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

commit: 6e0bc34

@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: 0

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

81-83: Add a comma after "Currently" for better readability.

A minor grammatical improvement would make this sentence flow better.

-tRPC converts many octet content types to a `ReadableStream` which can be consumed in a procedure. Currently these are `Blob` `Uint8Array` and `File`.
+tRPC converts many octet content types to a `ReadableStream` which can be consumed in a procedure. Currently, these are `Blob`, `Uint8Array`, and `File`.
🧰 Tools
πŸͺ› LanguageTool

[uncategorized] ~83-~83: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)


1-104: Consider adding error handling examples.

While the current documentation covers the basics well, it would be beneficial to include information about how to handle errors that might occur when processing non-JSON content types, especially for binary data.

Also, adding a brief explanation of when developers might want to use non-JSON types instead of JSON would provide useful context for readers.

🧰 Tools
πŸͺ› LanguageTool

[uncategorized] ~83-~83: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 6ef21fc and 5f9fb6e.

πŸ“’ Files selected for processing (3)
  • www/docs/server/non-json-content-types.md (1 hunks)
  • www/docs/server/validators.md (0 hunks)
  • www/sidebars.ts (1 hunks)
πŸ’€ Files with no reviewable changes (1)
  • www/docs/server/validators.md
🧰 Additional context used
πŸͺ› LanguageTool
www/docs/server/non-json-content-types.md

[uncategorized] ~83-~83: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: E2E-tests (nuxt)
  • GitHub Check: E2E-tests (vercel-edge-runtime)
  • GitHub Check: E2E-tests (next-formdata)
  • GitHub Check: E2E-tests (next-prisma-websockets-starter)
  • GitHub Check: E2E-tests (next-minimal-starter)
  • GitHub Check: E2E-tests (tanstack-start)
  • GitHub Check: E2E-tests (next-prisma-todomvc)
  • GitHub Check: E2E-tests (next-prisma-starter)
  • GitHub Check: E2E-tests (minimal-react)
  • GitHub Check: E2E-tests (cloudflare-workers)
  • GitHub Check: E2E-tests (express-minimal)
πŸ”‡ Additional comments (6)
www/sidebars.ts (1)

37-37: LGTM! New documentation entry added to sidebar.

The addition of the 'server/non-json-content-types' entry to the Backend Usage section is well-placed and provides a logical navigation option for users looking for information on handling non-JSON data types.

www/docs/server/non-json-content-types.md (5)

1-6: LGTM! Well-structured document metadata.

The metadata section correctly defines the document ID, title, sidebar label, and URL slug for the new documentation page.


8-9: LGTM! Good introduction.

This brief introduction clearly states the purpose of the document - explaining how tRPC handles non-JSON content types.


10-53: LGTM! Clear client setup instructions.

The client setup section provides comprehensive instructions for configuring tRPC clients to handle non-JSON content types, with clear examples for both simple and complex configurations.


55-79: LGTM! Well-documented FormData example.

This section effectively demonstrates how to use FormData with tRPC, including a helpful reference to the zod-form-data library for type-safe validation.


85-104: LGTM! Good example of binary type handling.

The code example clearly demonstrates how to use the octetInputParser for handling binary data types.

juliusmarminge
juliusmarminge previously approved these changes Apr 11, 2025

@juliusmarminge juliusmarminge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

few nits

@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: 0

♻️ Duplicate comments (1)
www/docs/server/non-json-content-types.md (1)

10-17: Client Setup Section

The β€œClient Setup” section is well-organized and provides a clear example. The use of the :::warning block (as opposed to an :::info block) reflects previous discussions and is acceptable if you want to emphasize a common pitfall.

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

8-9: Introduction and Overview

The introductory text succinctly explains that tRPC can handle non-JSON types (e.g., FormData, File, and other binary types) as procedure inputs. Consider ensuring consistent terminology (e.g., always using β€œnon-JSON” in the same style).


82-85: File and Binary Type Inputs

The explanation of how tRPC converts octet content types to a ReadableStream is clear. However, to improve grammatical clarity, consider inserting a comma after "Currently" and adding commas between the listed types. For example:

- tRPC converts many octet content types to a `ReadableStream` which can be consumed in a procedure. Currently these are `Blob` `Uint8Array` and `File`.
+ tRPC converts many octet content types to a `ReadableStream` which can be consumed in a procedure. Currently, these are `Blob`, `Uint8Array`, and `File`.
🧰 Tools
πŸͺ› LanguageTool

[uncategorized] ~84-~84: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 4190b8f and 16979c7.

πŸ“’ Files selected for processing (1)
  • www/docs/server/non-json-content-types.md (1 hunks)
🧰 Additional context used
πŸͺ› LanguageTool
www/docs/server/non-json-content-types.md

[uncategorized] ~80-~80: Possible missing comma found.
Context: ... }), }); ``` For a more advanced code sample you can see our [example project here](...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~84-~84: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: E2E-tests (next-minimal-starter)
  • GitHub Check: E2E-tests (standalone-server)
  • GitHub Check: E2E-tests (tanstack-start)
  • GitHub Check: E2E-tests (nuxt)
  • GitHub Check: E2E-tests (minimal-react)
  • GitHub Check: E2E-tests (soa)
  • GitHub Check: E2E-tests (fastify-server)
  • GitHub Check: E2E-tests (next-formdata)
  • GitHub Check: E2E-tests (next-prisma-starter)
  • GitHub Check: E2E-tests (next-prisma-websockets-starter)
  • GitHub Check: E2E-tests (express-server)
  • GitHub Check: E2E-tests (next-prisma-todomvc)
  • GitHub Check: E2E-tests (.test/ssg)
  • GitHub Check: Release using pkg.pr.new
  • GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
  • GitHub Check: test
πŸ”‡ Additional comments (7)
www/docs/server/non-json-content-types.md (7)

1-6: YAML Front Matter Clarity

The metadata in the YAML front matter is clear and provides an informative overview of the document's purpose.


18-28: HTTP Link Example

The example using httpLink is clear and straightforward. It effectively illustrates how to set up a client with non-JSON content support when only using this link.


30-53: SplitLink Example

The example showcasing splitLink is well-demonstrated, with a clear conditional that checks for non-JSON serializable inputs. This should help users configure their client correctly when using other link types such as httpBatchLink or httpBatchStreamLink.


55-58: FormData Input Description

The explanation of how FormData is supported (including referencing the zod-form-data library for type-safe validation) adds valuable context and directs users to a useful resource.


59-78: FormData Example Code

The provided code snippet for handling FormData is clear and effective. It illustrates the use of zod for input validation and demonstrates procedure creation in a concise way.


80-81: External Example Link

The external link to the advanced example project is a helpful resource for users seeking additional context or more complex use cases.

🧰 Tools
πŸͺ› LanguageTool

[uncategorized] ~80-~80: Possible missing comma found.
Context: ... }), }); ``` For a more advanced code sample you can see our [example project here](...

(AI_HYDRA_LEO_MISSING_COMMA)


86-105: Binary Input Example Code

The code snippet demonstrating binary input handling with octetInputParser is consistent with the earlier examples and clearly conveys how to process binary data in tRPC.

@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: 0

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

10-14: Client Setup Info Block Review.
The info block (using :::info) clearly warns that while tRPC supports non-JSON types natively, extra link configuration might be needed depending on the client setup. Please ensure that using the :::info style is consistent with similar documentation elsewhere in the project.


16-28: httpLink Code Example is Informative.
The code snippet for setting up a client with httpLink is concise and easy to follow. Consider adding a brief note or comment indicating that the url is expected to be defined externally (or provided via configuration) for clarity.


30-53: splitLink Code Example is Comprehensive.
The example demonstrates how to conditionally choose between links (using httpLink for non-JSON types and httpBatchLink for other cases) via splitLink, which is very useful. It would enhance clarity to include a comment noting that the url variable should be defined or imported from configuration.


80-81: Reference to Advanced Example.
Linking to an external advanced example project is beneficial for users who want more details. Please verify periodically that the link remains up-to-date and accessible.


82-84: Binary Input Explanation – Minor Punctuation Suggestion.
The explanation correctly notes that tRPC converts octet content types into a ReadableStream. As a minor improvement, add a comma after β€œCurrently” on line 84 for better readability:

β€œ... which can be consumed in a procedure. Currently, these are Blob Uint8Array and File.”

🧰 Tools
πŸͺ› LanguageTool

[uncategorized] ~84-~84: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 16979c7 and 6e0bc34.

πŸ“’ Files selected for processing (1)
  • www/docs/server/non-json-content-types.md (1 hunks)
🧰 Additional context used
πŸͺ› LanguageTool
www/docs/server/non-json-content-types.md

[uncategorized] ~84-~84: A comma may be missing after the conjunctive/linking adverb β€˜Currently’.
Context: ...which can be consumed in a procedure. Currently these areBlob Uint8ArrayandFile...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

πŸ”‡ Additional comments (4)
www/docs/server/non-json-content-types.md (4)

1-6: YAML Front Matter is Correct.
The front matter correctly defines the document’s metadata (ID, title, sidebar label, and slug), which will help with proper navigation and linking within the docs.


8-9: Introduction Text is Clear.
The introductory sentence succinctly explains that in addition to JSON, tRPC can process FormData, File, and other binary types.


55-78: FormData Input Example is Well-Structured.
The FormData example effectively shows how to use zod for type validation with FormData inputs. Ensure that any assumptions regarding the availability of FormData in different runtime environments (e.g., Node vs. browser) are documented, perhaps with a reference or footnote.


86-105: Binary Input Code Example is Accurate.
The code sample using the octetInputParser is clear and effectively demonstrates how to handle binary data through tRPC. This example aligns well with the narrative in the documentation.

@Nick-Lucas
Nick-Lucas merged commit 8ceef3a into main Apr 13, 2025
@Nick-Lucas
Nick-Lucas deleted the formdata-docs branch April 13, 2025 12:42
@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 Apr 14, 2025

This branch was successfully deployed

5 active deployments
Preview – www β€” 6e0bc347 Deployed Apr 13, 2025 by vercel[bot]
Preview – examples-todomvc β€” 6e0bc347 Deployed Apr 13, 2025 by vercel[bot]
Preview – og-image β€” 6e0bc347 Deployed Apr 13, 2025 by vercel[bot]
Preview – next-prisma-starter β€” 6e0bc347 Deployed Apr 13, 2025 by vercel[bot]
Preview – trpc-next-app-dir β€” 6e0bc347 Deployed Apr 13, 2025 by vercel[bot]
trpc-pr-6699 β€” 6e0bc347 Deployed Apr 13, 2025 by railway-app[bot]
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.

2 participants