Skip to content

Error while generating from schema with enum and custom prisma output folder #485

@bphkns

Description

@bphkns

Description and expected behavior

If the client generator has different output folder then running generate throws error if schema contains enum.

For eg if we have the schema like below

generator client {
  provider = "prisma-client-js"
  output   = "../../../../node_modules/.prisma/abc-client"
  previewFeatures = ["fullTextSearch"]
}

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

enum Role {
  SUPER_ADMIN
  ADMIN
  USER
}

It throws errors while running npx zenstack generate

node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/.zenstack/policy.ts:3:10 - error TS2305: Module '"@prisma/client"' has no exported member 'Role'.
3 import { Role } from "@prisma/client";
           ~~~~
node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/.zenstack/policy.ts:4:10 - error TS2305: Module '"@prisma/client"' has no exported member 'Status'.
4 import { Status } from "@prisma/client";
           ~~~~~~
✖ Running plugin Access Policy
: Error compiling generated code

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • ZenStack version: 1.0.0-alpha.126
  • Prisma version: 4.15.0
  • Database type: Postgresql

Additional context
If we remove the enum from the schema it complies fine and works as expected

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions