zenstack
zenstack copied to clipboard
[BUG] - tRPC plugin with zenstack output option
Description and expected behavior
I want to know if this is a bug or a missing configuration when using the tRPC plugin with zenstack generate --output option.
The generated zenstack tRPC code it's using the @zenstackhq/runtime/zod/input instead of {path}/generated/zenstack, as in the screenshot
Is this right?
Thanks!
Screenshots
Environment (please complete the following information):
- ZenStack version: [e.g., 2.16.0]
- Prisma version: [e.g., 6.10.1]
- Database type: [e.g. any]
You can customize the Zod import path using the zodSchemasImport option.
plugin trpc {
provider = '@zenstackhq/trpc'
output = 'server/routers/generated'
version = "v11"
importCreateRouter = "../../_app"
importProcedure = "../../_app"
generateClientHelpers = 'next'
zodSchemasImport = '@generated/zenstack/zod' // Add this line
}
However, do not add the (deprecated) output option in the enhancer plugin configuration.
plugin enhancer {
provider = '@core/enhancer'
output = 'generated/zenstack' // do NOT add this line
}
Doing so will cause runtime errors (e.g., with tRPC or hooks), such as:
[
{
"error": {
"json": {
"message": "Cannot read properties of undefined (reading 'TodoPrismaUpdateSchema')",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"stack": "Error calling enhanced Prisma method `todo.update`: Cannot read properties of undefined (reading 'TodoPrismaUpdateSchema')\n at eval (webpack-internal:///(api)/./server/routers/generated/routers/Todo.router.ts:78:112),\n at resolveMiddleware (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:102:36),\n at callRecursive (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:152:38),\n at Object.next (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:161:32),\n at inputValidatorMiddleware (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/middleware.mjs:56:21),\n at async callRecursive (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:152:32),\n at async eval (webpack-internal:///(api)/./server/routers/_app.ts:65:18),\n at async callRecursive (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:152:32),\n at async procedure (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:182:24),\n at async file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveResponse.mjs:194:30,\n at async Promise.all (index 0),\n at async resolveResponse (file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveResponse.mjs:409:26),\n at async file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/adapters/node-http/nodeHTTPRequestHandler.mjs:28:26,\n at async file:///Users/augustin/Documents/Dev/Test/sample-todo-trpc/node_modules/@trpc/server/dist/adapters/next.mjs:46:9",
"path": "todo.update",
"prismaError": null
}
},
"meta": {
"values": {
"data.prismaError": [
"undefined"
]
}
}
}
}
]