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

Entity types cannot be resolved in PNPM monorepo #99

Closed
gurvancampion opened this issue Jul 10, 2021 · 6 comments
Closed

Entity types cannot be resolved in PNPM monorepo #99

gurvancampion opened this issue Jul 10, 2021 · 6 comments
Assignees
Labels
generator Related to the Prisma generator part of Nexus Prisma needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. type/bug Something is not working the way it should

Comments

@gurvancampion
Copy link

I'm having trouble running nexus-prisma in PNPM monorepo. I have two packages users & posts, when I run the command prisma run generate, nexus-prisma get resolved at the root directory instead of the package directory. Which causes entity types cannot be resolved as they got overwritten.

What should be expected is the generated output should be at the package node_modules level instead of the root directory, like @prisma/client in the screenshot below.

Screenshot

image

It's a similar issue to this one for Prisma: prisma/prisma#7484

@gurvancampion gurvancampion added the type/bug Something is not working the way it should label Jul 10, 2021
@jasonkuhrt jasonkuhrt added the generator Related to the Prisma generator part of Nexus Prisma label Aug 26, 2021
@jasonkuhrt jasonkuhrt self-assigned this Aug 26, 2021
@jasonkuhrt
Copy link
Member

jasonkuhrt commented Aug 26, 2021

Resolution is currently relative to where nexus-prisma is installed on disk.

What algorithm do you suggest to solve this?

I do not know how pnpm works.

@jasonkuhrt jasonkuhrt added the needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. label Aug 26, 2021
@millsp
Copy link

millsp commented Aug 27, 2021

Yes, that's right. Because we resolve the client relatively to where the prisma is installed, we end up using the hoisted node_modules at the root of your project (your workspace). Here's an example project to shows how to do this with pnpm:
https://github.com/prisma/e2e-tests/tree/dev/packagers/pnpm-workspaces-custom-output

Notice here that the import is not @prisma/client any longer but .prisma/client.

And a more detailed explanation of this, follow here prisma/prisma#6603 (comment)

Let me know if it helped.

@jasonkuhrt
Copy link
Member

@millsp Are you saying the way nexus-prisma imports @prisma/client needs to change?

@jasonkuhrt
Copy link
Member

@millsp in that example the output has been customized https://github.com/prisma/e2e-tests/blob/dev/packagers/pnpm-workspaces-custom-output/workspace/sub-project-2/prisma/schema.prisma#L3.

NP would use that as the import specifier.

So I see nothing new that NP needs to do.

@millsp
Copy link

millsp commented Aug 28, 2021

Yep, custom output is the way to make it work with hoisted node_modules. Just need for @gurvan-guss to confirm if that worked.

@gurvancampion
Copy link
Author

Yes I confirm it worked by specifying a custom output :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Related to the Prisma generator part of Nexus Prisma needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. type/bug Something is not working the way it should
Projects
None yet
Development

No branches or pull requests

3 participants