vegardit / prisma-generator-nestjs-dto

Generates NestJS DTO classes from Prisma Schema
Apache License 2.0
274 stars 76 forks source link

Prisma Generate: MongoDB throws related model not found when using Types #132

Open nalham opened 2 years ago

nalham commented 2 years ago

In this scenario, I have a nested Document type that isn't a database indexed item.

Let's use Foo and Oof both needing access to the type of Bar.

file: schema.prisma

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

datasource db {
  provider = "mongodb"
  url      = "{urlOmitted}"
}

generator nestjsDto {
  provider                        = "prisma-generator-nestjs-dto"
  output                          = "../src"
  outputToNestJsResourceStructure = "true"
}

type Bar {
  thing1 String
  thing2 Int
  thing3 Boolean
}

model Foo {
  id            String          @id @default(auto()) @map("_id") @db.ObjectId
  bar          Bar
  thing       Int
}

model Oof {
  id            String          @id @default(auto()) @map("_id") @db.ObjectId
  bar          Bar
  thing      String
}

Upon generation, an error is thrown Error: related model 'Bar' for 'Foo.bar' not found

npx prisma generate
Prisma schema loaded from prisma/schema.prisma
prisma:info Processing Model Foo
Error:
✔ Generated Prisma Client (3.14.0 | library) to ./node_modules/@prisma/client in 74ms

Error: related model 'Bar' for 'Foo.bar' not found
eliasblume commented 1 year ago

I have the same issue. I guess this is just not supported with the current version... Any chance that this will be added?

gwesterman commented 1 year ago

Can't use this library or any of the current forks I found until this is resolved.