peternovak
peternovakβ€’16mo 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 πŸ±β€’16mo ago
you're using batching
Alex / KATT 🐱
Alex / KATT πŸ±β€’16mo 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 πŸ±β€’16mo 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β€’16mo ago
you should be able to just await them in order
peternovak
peternovakOPβ€’16mo 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β€’16mo 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
peternovakOPβ€’16mo 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)