I'm migrating standard REST Api to tRPC. I had the endpoints:
- GET
/api/auth
(get auth info about a user) - POST
/api/auth
(auth a user)
In the tRPC router, I cannot add query
and mutation
to the same route. Obviously, I have an error
TS1117: An object literal cannot have multiple properties with the same name.
for an object I pass to the router.
auth: authedProcedure
.query(({ ctx }) => ({ account: ctx.account })),
auth: publicProcedure
.mutation(({ ctx }) => ({ foo: 'bar' })),
Can query
and mutation
be combined for one route (using different procedures)?
How to deal with this case?