MichalLytek / typegraphql-prisma

Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema

Home Page:https://prisma.typegraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slow prisma generate

baptistemanson opened this issue · comments

Describe the Bug
With one model, I get
✔ Generated Prisma Client (4.15.0 | library) to .\node_modules@prisma\client in 53ms
✔ Generated TypeGraphQL integration to .\node_modules@generated\type-graphql in 69.38s

When testing with a larger schema (19 models) it takes 90-100s.

To Reproduce

generator client {
  provider = "prisma-client-js"
}

generator typegraphql {
  provider = "typegraphql-prisma"
}

datasource db {
  provider = "postgresql"
  url      = env("POSTGRES_MODEL_STRING")
}

model App {
  id String @id @default(uuid())
}

Expected Behavior
We would expect to be just a few seconds.

Environment (please complete the following information):

  • OS: Windows 11 (AMD Ryzen 9 3900X 12-Core Processor 3.80 GHz)
  • Node v20.3.1
  • typegraphql-prisma version 0.26
  • Prisma version 4.16
  • TypeScript version 5.0.3

We were also able to reproduce this issue with a macOS M1 environment.

{
  "extends": "ts-node/node16/tsconfig.json",
  "compilerOptions": {
    "target": "es2018",
    "lib": [
      "es2018",
      "esnext.asynciterable"
    ],
    "module": "commonjs",
    "outDir": "./dist",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  }
}

Have a great day! Tell me how I can help beyond funding (because broke for now)

Some progress; a custom folder outside out of the node_modules brings the performance to some acceptable performance.
Generated TypeGraphQL integration to .\src\server\middlewares\graphql in 574ms
for the large model
Generated TypeGraphQL integration to .\src\server\middlewares\graphql in 6.15s

On my machine with such schema:
https://github.com/MichalLytek/typegraphql-prisma/blob/main/experiments/postgres/prisma/schema.prisma

✔ Generated Prisma Client (4.15.0 | library) to ./prisma/generated/client in 83ms

✔ Generated TypeGraphQL integration to ./prisma/generated/type-graphql in 2.43s

https://github.com/MichalLytek/typegraphql-prisma/blob/main/experiments/postgres/prisma/schema.prisma

As stated in the docs, emitting to node_modules does transpilation of the generated TS code on the fly, that's why it's so slow.

Im glad we got a chance to find the solution and document it for future users.
As I use tsx now, I forgot transpilation with ts-node was so slow! Thanks for trying to run it too Michal, I appreciate.

I will close the bug.