Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prisma generate takes >20 seconds after adding typegraphql-prisma #90

Closed
dickfickling opened this issue Mar 29, 2021 · 15 comments
Closed
Labels
enhancement New feature or request priority:low This issue has a low priority and will be done after all the others

Comments

@dickfickling
Copy link

dickfickling commented Mar 29, 2021

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-prisma version 0.12.0
  • Prisma 2 version 2.19.0
  • TypeScript version 4.1.3
@MichalLytek
Copy link
Owner

Try emitting source code (TS files) instead of transpilled code into node_modules.

Might be related to #10

@MichalLytek MichalLytek added the enhancement New feature or request label Apr 1, 2021
@dickfickling
Copy link
Author

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.

@JClackett
Copy link

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?

@MichalLytek
Copy link
Owner

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

@MichalLytek MichalLytek added the priority:high This issue is important and will be done first label Nov 10, 2021
@MichalLytek MichalLytek added priority:low This issue has a low priority and will be done after all the others and removed priority:high This issue is important and will be done first labels Jul 27, 2022
@Colliot2
Copy link

Colliot2 commented Jul 9, 2023

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

@MichalLytek
Copy link
Owner

@Colliot2 disable on the fly transpilation and emit source code files

@at-vpd
Copy link

at-vpd commented Aug 27, 2023

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?

@MichalLytek
Copy link
Owner

@at-vpd emitTranspiledCode = false

@at-vpd
Copy link

at-vpd commented Aug 27, 2023

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.

@srosato
Copy link

srosato commented Sep 20, 2023

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

@srosato
Copy link

srosato commented Sep 21, 2023

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

@MitchellBarker
Copy link

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.

@dickfickling
Copy link
Author

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

@JClackett
Copy link

im still at 30s for my project, using 0.27.1

@srosato
Copy link

srosato commented Nov 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:low This issue has a low priority and will be done after all the others
Projects
None yet
Development

No branches or pull requests

7 participants