Is there a way to split a trpc api across multiple lambdas ?

How do I go about splitting my TRPC api across multiple lambdas, such that each lambda would load the minimum code it needs to run, (ideally the frontend should not be affected )
S
sachin242d ago
GitHub
trpc/examples/soa at main · trpc/trpc
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
AE
Ahmed Eid242d ago
hmm, interesting but probably not the best approach IMO.
S
sachin242d ago
if you think there’s a better approach, feel free to do a PR
AE
Ahmed Eid242d ago
I'm not sure, I think lazy loading routes would be a much better approach than this, would you agree ?
AE
Ahmed Eid242d ago
I had an idea which looks to be working, I'm using SST. I have a lambda per router. and I have a combing router ( fake ) which just exports the type for the frontend. I have attached some screenshots.
No description
No description
No description
No description
AE
Ahmed Eid242d ago
let me know what you think ?
AE
Ahmed Eid242d ago
actouer routes sould look like this
No description
AE
Ahmed Eid242d ago
each router has 2 lambdas, 1 for queries and another for mutations. the routes trick doesn't seem to be working ...
STS
Sassy The Sasquatch239d ago
Did you end up finding a solution to this, also using a similiar sst setup
M
medv233d ago
Need to explore this pretty soon as it is a non-starter for us and your idea looks pretty good. Very curious to hear what did not work and what you are doing now.
AE
Ahmed Eid219d ago
@sassythesasquatch_ pause looking into this for a while, will continue investigating.
AE
Ahmed Eid219d ago
@medv I believe trpc dot seperator was a blocker for me https://trpc.io/docs/rpc#accessing-nested-procedures it's not compatible with api gateway.
HTTP RPC Specification | tRPC
Methods Type mapping
AE
Ahmed Eid219d ago
it just need to be a /
M
medv218d ago
Thanks for responding. We aren't looking to host these in separate lambdas on separate endpoints, instead the modularization will occur with nestjs lazy loaded modules. I'd imagine the process for us will be slightly different as we do need the full router to be present at runtime, except one that is capable of mapping the request shape to the appropriate router path, at which point the lazy loading will occur. If we do get to this, I will write back here in the future.
M
medv218d ago
GitHub
feat: Lazy load routers · Issue #4129 · trpc/trpc
Describe the feature you'd like to request Basically next/dynamic but for the backend. Recently our tRPC router has been growing significantly for many reasons but mostly due to heavy third par...
AE
Ahmed Eid216d ago
lazy loading routers for TRPC would be an ideal solution for us too.
More Posts
Can I alter the context in a procedure?Is there a proper way to do this? Mutating the `opts.ctx` directly seems wrongtRPC & getInitialPropsSo I am not using Next new App router but cant figure it out how to call a method during SSR with geGetting 413 error in Vercel when batching several queries (using Next pages router)Hi guys, I'm having a weird error on Vercel: "LAMBDA_RUNTIME Failed to post handler success responsQueries work but mutations do notOdd bug I'm experiencing with TRPC + react-query + the koa adapter. I just set everything up per docuseContext utils getData always returning undefinedI have my app set up with TRPC and when trying to call ` const utils = trpc.useContext();` `consTRPC Error HandlingI am using TRPC as my backend for my nextjs application. The one major problem i am facing is that, CORS issue with Lambda Handler (SST)no idea what's going on with this error. been stuck on it for way too long. i tried adding the test-TRPC API not working for production buildI am using Trpc and next in project, The App is fully functional with dev build , but api's giving 4Get object type using UseTRPCQueryResultthis code ```ts type playlistOutputData = UseTRPCQueryResult< inferRouterOutputs<AppRouter>["notifNeed help with type hinting a function that accepts a trpc client router```js interface CreateModelProps<GetResult> { name: string, procedures: DecoratedProcedureReDatabase error on examples-next-prisma-starterHi, im on node 18.16.0. I'm trying to clone and use this : https://github.com/trpc/examples-next-priSet server response headers from TRPC standalone adapterHi I am trying to implement my own authentication in Trpc. For this I need to create a session on tReturn TRPC Error from NextJS middlewareI am using trpc for my app's api but Im using NextJS middleware + upstash ratelimitting for.... welluseContext not InvalidatingWhat are the possible mistakes if useContext wont invalidate when doing the following: ```ts const uDeduping is broken, but is being batchedHi all, We're using TRPC for our React Native app, while doing some testing, I saw in my server logQuestion about trpc revalidation methodalright I have a question, why can tRPC detect changes from the DB and refetch. but when I mutate thHow can I enable experimental Suspense on NextJSO have a project with trpc (v.10^) and nextjs 13, and I wanna test the suspense query, but not show Examples of Vitest with React Testing LibraryDoes anyone have examples of how to mock data from tRPC procedure calls? I have client components thHow to refetch based on different eventI have a procedure that fetches all products, I have another one that deletes a project given it's IDockerizing in TRPCHi guys, I am developing a Next app with TRPC subscriptions/websockets and am running into issues tr