feat: Streaming Mutations / Queries
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
Solution: feat: Streaming Mutations / Queries
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
Trust Score
2 verifications
- 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
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
With the classic react-query api, we'd receive a `data` object
[code block]
- 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
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep