omar-dulaimi / prisma-zod-generator

Prisma 2+ generator to emit Zod schemas from your Prisma schema
MIT License
513 stars 45 forks source link

Files not generated with Preview-Feature `prismaSchemaFolder` #95

Open timreibe opened 1 month ago

timreibe commented 1 month ago

Bug description

I'm using the Preview-Feature prismaSchemaFolder to have multiple schema files in dictionary prisma/schema.

However, when I run npx prisma generate, the output folder for the zod-files is created, but is empty.

How to reproduce

  1. Create directory prisma/schema
  2. Create schema.prisma file with following content:
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["prismaSchemaFolder"]
}

generator zod {
  provider          = "prisma-zod-generator"
  output            = "./generated-zod-schemas"
  isGenerateSelect  = true
  isGenerateInclude = true
}

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

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
  content   String?
  published Boolean  @default(false)
  viewCount Int      @default(0)
  author    User?    @relation(fields: [authorId], references: [id])
  authorId  Int?
  likes     BigInt
}
  1. run npx prisma generate
  2. folder generated-zod-schemas was created but is empty

Expected behavior

I'd expect the zod-files to be created.

The exact same prisma.schema file works without previewFeature flag prismaSchemaFolder

Prisma information

See above

Environment & setup

Prisma Version

prisma                  : 5.17.0
@prisma/client          : 5.17.0
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v22.0.0
Query Engine (Node-API) : libquery-engine 393aa359c9ad4a4bb28630fb5613f9c281cde053 (at node_modules/prisma/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli 393aa359c9ad4a4bb28630fb5613f9c281cde053 (at node_modules/prisma/node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053
Default Engines Hash    : 393aa359c9ad4a4bb28630fb5613f9c281cde053
Studio                  : 0.502.0
Preview Features        : prismaSchemaFolder
polesapart commented 2 weeks ago

it seems like any previewFeature has the same behavior; Here I have: previewFeatures = ["relationJoins"]