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

Generator crashes on composite types

halotest opened this issue · comments

Describe the Bug
Typegraphql-prisma generator fails if there's a composite type in prisma schema. Once composite type is removed, generator works as expected.

To Reproduce

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

generator typegraphql {
  provider = "typegraphql-prisma"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

type B {
  F String
}

model A {
  id String @id @map("_id") @db.ObjectId()
}

Expected Behavior
Generator should not crash.

Logs
Error:
✔ Generated Prisma Client (4.11.0 | library) to ./node_modules/@prisma/client in 24ms

Cannot read properties of undefined (reading 'fields')

Environment (please complete the following information):

  • OS: MacOS Ventura 13.0
  • Node (v19.5.0)
  • typegraphql-prisma: 0.24.2
  • Prisma version 4.11.0
  • TypeScript version 4.9.5

Why the B type is not used anywhere?

If you make the schema correct, all is working:

type B {
  F String
}

model A {
  id String @id @map("_id") @db.ObjectId()
  b  B
}

@MichalLytek Oh god, my bad. That makes sense and it works, thanks!