tRPCttRPC
Powered by
DavidD
tRPC•3y ago
David

standaloneMiddleware: Merge ctx/meta/input types

Using standaloneMiddleware, it would be great to merge the types (ctx, input, meta) with what is already there when passing that middleware.

In our case:
experimental_standaloneMiddleware<{ ctx: { user: { id: number } } }>()
experimental_standaloneMiddleware<{ ctx: { user: { id: number } } }>()

this is because we want to be sure user.id exists in the context before allowing the usage of this middleware, but when returning like this:
next({ ctx: { ...ctx, newProp: '' } })
next({ ctx: { ...ctx, newProp: '' } })
you would still want the context type to be merged with the original so your queries and mutations get the complete context.
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Why deprecate experimental_standaloneMiddleware?
GabrielGGabriel / ❓-help
2y ago
types not working if input provided
fynnFfynn / ❓-help
7mo ago
How to infer types from input?
PieterPPieter / ❓-help
3y ago