Repository navigation
Add dedicated non-json inputs page - #6699
Conversation
WalkthroughA 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
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
Poem
Tip β‘π¬ Agentic Chat (Pro Plan, General Availability)
πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
π Deployed to the trpc-pr-6699 environment in trpc-sse-and-websockets
|
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
@trpc/client
@trpc/next
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
There was a problem hiding this comment.
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 areBlobUint8ArrayandFile...(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 areBlobUint8ArrayandFile...(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π 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.
5f9fb6e to
ab3a89f
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
β»οΈ Duplicate comments (1)
www/docs/server/non-json-content-types.md (1)
10-17: Client Setup SectionThe βClient Setupβ section is well-organized and provides a clear example. The use of the
:::warningblock (as opposed to an:::infoblock) 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 OverviewThe 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 InputsThe explanation of how tRPC converts octet content types to a
ReadableStreamis 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 areBlobUint8ArrayandFile...(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π 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 ClarityThe metadata in the YAML front matter is clear and provides an informative overview of the document's purpose.
18-28: HTTP Link ExampleThe example using
httpLinkis 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 ExampleThe example showcasing
splitLinkis 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 ashttpBatchLinkorhttpBatchStreamLink.
55-58: FormData Input DescriptionThe explanation of how FormData is supported (including referencing the
zod-form-datalibrary for type-safe validation) adds valuable context and directs users to a useful resource.
59-78: FormData Example CodeThe provided code snippet for handling FormData is clear and effective. It illustrates the use of
zodfor input validation and demonstrates procedure creation in a concise way.
80-81: External Example LinkThe 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 CodeThe code snippet demonstrating binary input handling with
octetInputParseris consistent with the earlier examples and clearly conveys how to process binary data in tRPC.
Co-authored-by: Julius Marminge <[email protected]>
There was a problem hiding this comment.
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:::infostyle is consistent with similar documentation elsewhere in the project.
16-28: httpLink Code Example is Informative.
The code snippet for setting up a client withhttpLinkis concise and easy to follow. Consider adding a brief note or comment indicating that theurlis 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 (usinghttpLinkfor non-JSON types andhttpBatchLinkfor other cases) viasplitLink, which is very useful. It would enhance clarity to include a comment noting that theurlvariable 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 aReadableStream. 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
BlobUint8ArrayandFile.βπ§° 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 areBlobUint8ArrayandFile...(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π 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 usezodfor type validation with FormData inputs. Ensure that any assumptions regarding the availability ofFormDatain 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 theoctetInputParseris clear and effectively demonstrates how to handle binary data through tRPC. This example aligns well with the narrative in the documentation.
|
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. |
Closes #
π― Changes
What changes are made in this PR? Is it a feature or a bug fix?
β Checklist
Summary by CodeRabbit