FG
๐ŸŒ Web & Full-Stack

feat: Streaming Mutations / Queries

Freshalmost 2 years ago
Mar 14, 20260 views
Confidence Score88%
88%

Problem

Describe the feature you'd like to request Many upstream APIs (e.g. OpenAI's GPT) stream responses to the client. It would be great if TRPC supported such streaming requests. Describe the solution you'd like to see I'd imagine this would look like a mutation or query where the resolver is an async generator. Example: [code block] Describe alternate solutions An alternative is to set up subscriptions and map the mutation inputs to some identifier in the subscription. The problem with this approach is (a) it depends on websockets, which are difficult to support from an infrastructure perspective, (b) the race conditions between establishing a socket connection and corresponding this with mutations/queries can be miserable. Additional information I'd mostly like to understand any suggestions for how to approach this and whether you'd support a PR. Creating a `streamingMutation` procedure type, for instance, is fairly invasive but may be the correct approach. ๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing - [X] ๐Ÿ™‹โ€โ™‚๏ธ Yes, I'd be down to file a PR implementing this feature! [code block]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate2 verificationsLast verified Mar 14, 2026

Solution: feat: Streaming Mutations / Queries

Low Risk

I do like the idea, but I can't wrap my head around the ergonomics of consuming such a procedure. Here are my thoughts so far. --- Do you have an idea of the API you'd like for the client consuming such a request? With the classic react-query api, we'd receive a `data` object [code block] So, not considering implementation feasibility, what would this `data` object look like? Say the server i

84

Trust Score

2 verifications

100% success
  1. 1

    I do like the idea, but I can't wrap my head around the ergonomics of consuming

    I do like the idea, but I can't wrap my head around the ergonomics of consuming such a procedure. Here are my thoughts so far.

  2. 2

    Do you have an idea of the API you'd like for the client consuming such a reques

    Do you have an idea of the API you'd like for the client consuming such a request?

  3. 3

    With the classic react-query api, we'd receive a `data` object

    [code block]

  4. 4

    So, not considering implementation feasibility, what would this `data` object lo

    So, not considering implementation feasibility, what would this `data` object look like?

Validation

Resolved in trpc/trpc GitHub issue #4477. Community reactions: 1 upvotes.

Verification Summary

Worked: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

trpctypescriptapi