omar-dulaimi / prisma-joi-generator

Prisma 2+ generator to emit Joi schemas from your Prisma schema
MIT License
43 stars 9 forks source link

Support for Prisma 4.x #4

Closed Alexandre-Fernandez closed 2 years ago

Alexandre-Fernandez commented 2 years ago

It works perfectly on 3.15.2, but throws this error after running pnpm prisma generate on 4.0.0 :

Environment variables loaded from .env
Prisma schema loaded from src/api/database/schema.prisma
Error: 
✔ Generated Prisma Client (4.0.0 | library) to ./node_modules/.pnpm/@prisma+client@4.0.0_prisma@4.0.0/node_modules/@prisma/client in 53ms

TypeError: Cannot read properties of undefined (reading 'enumTypes')
    at Object.generate [as onGenerate] (.../node_modules/.pnpm/prisma-joi-generator@0.1.1_prisma@4.0.0/node_modules/prisma-joi-generator/lib/prisma-generator.js:45:36)
    at async LineStream.<anonymous> (.../node_modules/.pnpm/@prisma+generator-helper@3.15.0/node_modules/@prisma/generator-helper/dist/generatorHandler.js:33:24)
omar-dulaimi commented 2 years ago

Hey @Alexandre-Fernandez Thanks for using my project, I appreciate it.

Yes, indeed there has been a breaking change in Prisma internals. It looked a minor change judging by the release notes. I'm planning to dedicate some time to upgrade this generator and all other generators I have.

Hopefully soon enough.

Though if you feel adventurous, you could give it a go. Start by checking the release notes regarding Prisma's internals, that's where you would need to begin.

omar-dulaimi commented 2 years ago

Done in https://github.com/omar-dulaimi/prisma-joi-generator/releases/tag/0.2.0