omar-dulaimi / prisma-zod-generator

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

[Error] Strange `ERROR undefined` with `trpc` and `nuxt` #70

Closed mubaidr closed 1 year ago

mubaidr commented 1 year ago

Bug description

When using generated zod types with trpc and nuxt nitro server prints strange info.

Screenshot_20230102_215640

How to reproduce

  1. Create nuxt
  2. add trpc-nuxt
  3. generate prisma-zod-generator
  4. User generated zod type in input for trpc
  5. Check console for nitro server

Expected behavior

There should be no error

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["extendedWhereUnique", "filteredRelationCount", "orderByNulls"]
}

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

// generator trpc {
//   provider           = "prisma-trpc-generator"
//   output             = "./generated/trpc"
//   contextPath        = "../context"
//   withMiddleware     = false
//   withShield         = false
//   isGenerateSelect   = false
//   isGenerateInclude  = false
// }

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

model City {
  id              Int             @id @default(autoincrement())
  title           String          @unique
  createdAt       DateTime        @default(now()) @map("created_at") @db.Timestamptz
  updatedAt       DateTime        @default(now()) @map("updated_at") @db.Timestamptz
  venues          Venue[]

  @@map("city")
}

model Venue {
  id        Int      @id @default(autoincrement())
  code      String   @unique
  title     String   @unique
  address   String
  capacity  Int
  available Boolean  @default(true)
  cityId    Int      @map("city_id")
  createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
  updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
  city      City     @relation(fields: [cityId], references: [id])

  @@map("venue")
}

Environment & setup

Prisma Version

prisma                  : 4.8.0
@prisma/client          : 4.8.0
Current platform        : debian-openssl-3.0.x
Query Engine (Node-API) : libquery-engine d6e67a83f971b175a593ccc12e15c4a757f93ffe (at node_modules/.pnpm/@prisma+engines@4.8.0/node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node)
Migration Engine        : migration-engine-cli d6e67a83f971b175a593ccc12e15c4a757f93ffe (at node_modules/.pnpm/@prisma+engines@4.8.0/node_modules/@prisma/engines/migration-engine-debian-openssl-3.0.x)
Introspection Engine    : introspection-core d6e67a83f971b175a593ccc12e15c4a757f93ffe (at node_modules/.pnpm/@prisma+engines@4.8.0/node_modules/@prisma/engines/introspection-engine-debian-openssl-3.0.x)
Format Binary           : prisma-fmt d6e67a83f971b175a593ccc12e15c4a757f93ffe (at node_modules/.pnpm/@prisma+engines@4.8.0/node_modules/@prisma/engines/prisma-fmt-debian-openssl-3.0.x)
Format Wasm             : @prisma/prisma-fmt-wasm 4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe
Default Engines Hash    : d6e67a83f971b175a593ccc12e15c4a757f93ffe
Studio                  : 0.479.0
Preview Features        : orderByNulls, filteredRelationCount, extendedWhereUnique
omar-dulaimi commented 1 year ago

I'm unfamiliar with Nuxt, so I would appreciate it if you provided a simple reproduction repo to examine this issue

mubaidr commented 1 year ago

Sure, I will arrange a minimal reproduction codebase. BTW I don't think this is related to nuxt, simply importing these generated models shall throw this error. But will confirm after creating a minimal repo. Thanks

omar-dulaimi commented 1 year ago

Any update on this?

mubaidr commented 1 year ago

Sorry, I could not get time to create a reproduction. Will re-open this issue once I have the repo.