peternovak
peternovakβ€’11mo ago

Call multiple TRPC endpoints from onSuccess()?

I would like to create an API chain for analysing a geographic area where one successful API call can lead to multiple new API's being called to render the components in the right orders for the user. This works really well for single API calls, but when combining multiple of them together to be triggered at a onSuccess() call, the trpc combines them all together instead of taking them one by one. Does anyone know how to solve this?
No description
No description
7 Replies
Alex / KATT 🐱
Alex / KATT πŸ±β€’11mo ago
you're using batching
Alex / KATT 🐱
Alex / KATT πŸ±β€’11mo ago
HTTP Batch Link | tRPC
httpBatchLink is a terminating link that batches an array of individual tRPC operations into a single HTTP request that's sent to a single tRPC procedure.
Alex / KATT 🐱
Alex / KATT πŸ±β€’11mo ago
Split Link | tRPC
splitLink is a link that allows you to branch your link chain's execution depending on a given condition. Both the true and false branches are required. You can provide just one link, or multiple links per branch via an array.
sachin
sachinβ€’11mo ago
you should be able to just await them in order
peternovak
peternovakβ€’10mo ago
Thanks @alexkatt , this httpBatchLink was exactly the documentation I was looking for!! How would that kind of structure look like @sachinraja ? Keen to give it a try!
sachin
sachinβ€’10mo ago
sorry i misunderstood what you were asking - alex's solution works for what you want here why don’t you want them to be batched though?
peternovak
peternovakβ€’10mo ago
The polygon that I am sending from my frontend is about 300kb, so if I batch these endpoints together I am hitting the cap of 1MB max limit of TRPC (and I didn't manage to figure out how to increase it)
More Posts
How to set sizeLimit > 1MB (to solve 413 error)?Hi all, I am trying out the T3 stack where I want to send area polygons given by the user to my NexHow to manage server to server communicationWould managing headers this way work in nextjs as server to server communication? or does next managReplacing the dot notation in URLs with forward slash `/` ?is there a way to replace the dot separation with a forward slash instead ? so instead of `/api/tWhich one method should I use for creating trpc for server componetns in Nextjs 13 App dirHi which one I should use experimental_createTRPCNextAppDirServer or createTRPCProxyClient when it cCan someone explain to me the use of tRPC in server components?I can really see the need for tRPC in client components but can someone explain to me how you would Error-Boundary and TRPCIs there a nice way to catch errors from TRPC at a global level and bubble them into a simple alert Type errors in lambda integrationI really don't know where to start with this error.... I'm going to be integrating tRPC into a lambHybrid application with offline and online mode setup with tRPCHi, I was wondering if I could setup tRPC in way that one http link is using local API (for offline query with no input reports errori have a simple router with a list procedure that takes no input and just does a .query() it used tNext cookies() not being set on Mutation in App Dir (T3 Turbo)Trying to set cookies inside TRPC using Nextjs App Router, using the T3 Turbo setup. Setting cookie