tRPCttRPC
Powered by
patrickP
tRPC•4y ago•
4 replies
patrick

dynamic router creation

has anyone been able to create a dynamic router?
e.g. i pass in the schema and some metadata and it produces the same routes but they are selected down to the metadata?
my use case is i want to have crud against a set of tables...
so i create a zod schema for each entity and want to create a router that does list, get, create, update, and delete, but for that one table, then i create one of each of these one per table...
with what i've written, i'm getting the dreaded ts(2742) error....
The inferred type of 'routerForTable' cannot be named without a reference to '../../node_modules/@trpc/server/dist/core/parser.js'. This is likely not portable. A type annotation is necessary
The inferred type of 'routerForTable' cannot be named without a reference to '../../node_modules/@trpc/server/dist/core/parser.js'. This is likely not portable. A type annotation is necessary

trying to pass in the schema as
T extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam>
T extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam>
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How can you fetch data on a dynamic router with trpc?
josephbranchJjosephbranch / ❓-help
3y ago
Migrating pages router to app router
spreen_coSspreen_co / ❓-help
11mo ago