typegraphql-prisma
typegraphql-prisma copied to clipboard
`prisma generate` takes >20 seconds after adding typegraphql-prisma
Describe the Bug
Not sure if this is a bug or a feature request, but it takes more 20 seconds to run prisma generate with the typegraphql generator enabled. Generating the prisma client itself takes 500ms.
If this is a known issue and you just haven't gotten around to doing some perf profiling, let me know and I'll be happy to dig in myself
To Reproduce I'm hesitant to share my entire schema file publicly, but am happy to send it privately if you need it to diagnose. It has 31 models averaging 6-10 columns, and 66 relations.
Expected Behavior I'd expect generation to take a few seconds at most
Logs
✔ Generated Prisma Client (2.19.0) to ./node_modules/@prisma/client in 554ms
✔ Generated TypeGraphQL integration to ./node_modules/@generated/type-graphql in 22.54s
Environment (please complete the following information):
- OS: MacOS 11.2.3 on M1 Macbook Air
- Node 15.9.0
typegraphql-prismaversion 0.12.0- Prisma 2 version 2.19.0
- TypeScript version 4.1.3
Try emitting source code (TS files) instead of transpilled code into node_modules.
Might be related to #10
Thanks, this helped a bit (or at least, moved the time from prisma generate to tsc).
Not necessarily a typegraphql-prisma question, but are you aware of a good pattern to alter all the outputted files? They've got a bunch of unused imports / local vars that causes tsc to fail if we have noUnusedLocals enabled in our tsconfig. For now I've just disabled that rule, but i'd rather automatically add // @ts-nocheck to the top of all the typegraphql-prisma-generated files.
Yeah emitting the source files comes with a load of new issues, like eslint/tsc errors, not to mention starting any ts server takes a while to boot
is there a way to disable the generation of resolvers and only generate Inputs, Args and Models?
is there a way to disable the generation of resolvers and only generate Inputs, Args and Models?
Please create a separate issue in order to track this
Is anyone actively working on this issue? The generation time is incredibly long, while I only have two tables:
✔ Generated Prisma Client (4.16.0 | library) to ./node_modules/@prisma/client in 142ms
✔ Generated TypeGraphQL integration to ./node_modules/@generated/type-graphql in 104.33s
@Colliot2 disable on the fly transpilation and emit source code files
how do I do this? I have
emitTranspiledCode = true but the generation is still taking 70 seconds, I have emitOnly = ["models", "inputs","enums"] also. Is there anything I need to be setting?
@at-vpd emitTranspiledCode = false
Thanks for the quick reply - I got it working by bringing TS down a version, I was on v5.2.2, v5.0.4 brings it down to 8 seconds rather than 70s.
Why is transpilation so much longer? When I use prisma v4 I get a 8s generation (with transpilation), but when switching to v5 it goes to 47s. I can stop emiting transpilation but then I run into other problems. I will try to give more info as I dig into my own problem (nx + pnpm + prisma v5)
I tried downgrading TypeScript version to 5.0.4 but it did not help
I ended up downgrading to prisma@~4.3.1 with typegraphql-prisma@^0.21.5
I tried multiple versions with the same codebase, my schema file is relatively simple.
| Packages | Generation Time |
|---|---|
prisma@^5.2.0 typegraphql-prisma@^0.27.0 typescript@^5.2.2 prisma-field-encryption@^1.5.0 |
~46s |
prisma@^4.16.2 typegraphql-prisma@^0.26.0 typescript@^5.2.2 prisma-field-encryption@^1.5.0 |
~45s |
prisma@^4.16.2 typegraphql-prisma@^0.26.0 typescript@^4.7.4 prisma-field-encryption@^1.5.0 |
~46s |
prisma@~4.3.1, typegraphql-prisma@^0.21.5, typescript@^5.2.2, prisma-field-encryption@~1.4.5 |
~8s |
Yeah it was working fine for me on prisma@^4.7.1 and typegraphql-prisma@^0.23.1. Tried upgrading to typegraphql-prisma@^0.26.0 and it took like 100s for about 30 models (and resolvers). I'd not care too much, but my github actions started failing in CI because of the memory load.
I don't think setting emitTranspiledCode to false will work for me, but it did bring the time down to ms.
I settled on typegraphql-prisma@^0.25.0 with prisma@^4.13.1 which brought the time up to 20s and seemed to not crash my github actions.
for anybody watching this issue, i'm pretty sure @MichalLytek fixed it in 0.27.1. Time spent generating has dropped from 60s to 5s on my project
im still at 30s for my project, using 0.27.1
I also noticed significant improvement on typegraphql-prisma@^0.27.1 and prisma v5 at around ~9s instead of ~46s.
I tried pothos though meanwhile and it was very fast for me (around ~800ms), but did not feel like migrating my whole project just to gain that benefit, but it is a significant difference, but it is probably because I am transpilling files and not just emitting the ts files.