Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad prisma-client import #9

Closed
altarrok opened this issue Jul 29, 2022 · 5 comments · Fixed by #10
Closed

Bad prisma-client import #9

altarrok opened this issue Jul 29, 2022 · 5 comments · Fixed by #10
Assignees
Labels
bug Something isn't working

Comments

@altarrok
Copy link
Contributor

Bug description

Generated object schemas have a bad prisma-client import when client output is "../src/generated/prisma-client" and zod output is "../src/generated/zod" in Windows:

import type { Prisma } from '......prisma-client';

How to reproduce

  1. add output = "../src/generated/prisma-client" to client generator config in schema.prisma
  2. add output = "../src/generated/zod" to zod generator config in schema.prisma
  3. Run yarn prisma generate
  4. Go to src\generated\zod\schemas\objects\XCreateInput.schema.ts
  5. See import type { Prisma } from '......prisma-client';

Expected behavior

import type { Prisma } from '../../../prisma-client';

Prisma information

generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma-client"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}

generator zod {
provider = "prisma-zod-generator"
output = "../src/generated/zod"
}

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

model X {
id String @id @default(auto()) @Map("_id") @db.ObjectId
}

Environment & setup

  • OS: Windows
  • Database: Mongo
  • Node.js version: v18.6.0

Prisma Version

prisma                  : 4.1.0
@prisma/client          : 4.1.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 8d8414deb360336e4698a65aa45a1fbaf1ce13d8
Studio                  : 0.467.
@omar-dulaimi
Copy link
Owner

Hey @altarrok

Sadly, I do not have a Windows machine to try it out. On my Linux machine though, your config worked fine and generated this import:

import type { Prisma } from '../../../prisma-client';

So, is it possible that you attempt fixing this?
I'm more than happy to accept your changes and guide you along the way.

Also, don't forget to star this project if you find it helpful :)

@altarrok
Copy link
Contributor Author

@omar-dulaimi Yeah sure, I already implemented a fix, I don't have the perms tho, how can I create a PR? thx

@omar-dulaimi
Copy link
Owner

@altarrok
1- Fork
2- Clone
3- Create a local branch for the fix
4- Push to your fork
5- From your Github repo, create PR

@altarrok
Copy link
Contributor Author

@omar-dulaimi thanks for the steps, created the PR: #10

@omar-dulaimi omar-dulaimi self-assigned this Jul 30, 2022
@omar-dulaimi omar-dulaimi added the bug Something isn't working label Jul 30, 2022
@omar-dulaimi omar-dulaimi linked a pull request Jul 30, 2022 that will close this issue
@omar-dulaimi
Copy link
Owner

@altarrok Thanks for your contribution. Any others you have are welcomed, just make sure to start an issue first so we can discuss it :)

Released in: https://github.com/omar-dulaimi/prisma-zod-generator/releases/tag/0.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants