Is it possible to send a progress status with tRPC?

I have some tRPC mutations that take a while 20s+ and would like to give the user an idea of how far along it is. is there a way I get send back some data to the client to show the progress?
5 Replies
Lukem121
Lukem121OP2y ago
Can i send a number from 1-100?
needmorewood
needmorewood2y ago
if you are using the tanstack query wrapper you can take in isFetching but that would just be a boolean
Keef
Keef2y ago
When you say progress I think of long running jobs, serverless functions generally won't be able to do that on their own You could use a job queue that emits progress events and you can just do something with them like send them to a user's websocket or update the record in the db and consume those on the front end Someone correct me if im wrong tho
needmorewood
needmorewood2y ago
in wouldnt run any rest like thing for that long if i could avoid it asynchrounous jobs are def the way to go if you can it kinda depends on the situation though if u need the update back on client immediatly it may not be possible but if thats the case maybe u fix the 20s part as thats the issue.... idk
Keef
Keef2y ago
You could just update a record in a table that holds the status of the "job" which is updated at different points in your mutation and just use a second query to check the status of the job Thats prob the simplest way without having to get a bunch of things involved but using just a MUTATION is prob not
Want results from more Discord servers?
Add your server