Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
95 stars 16 forks source link

pnpm support #40

Closed larsivi closed 1 year ago

larsivi commented 1 year ago

I am trying to use this in a module a monorepo using pnpm.

When running "pnpx prisma generate", I first got:

Prisma schema loaded from schema/schema.prisma Error: Generator at prisma-pothos-types could not start:

/bin/sh: 1: prisma-pothos-types: not found

Then I added prisma-pothos-generator-codegen to public-hoist-pattern in .npmrc (seems to generally be a thing for various plugins). When running generate now I get

Prisma schema loaded from schema/schema.prisma npm ERR! code EUNSUPPORTEDPROTOCOL npm ERR! Unsupported URL Type "workspace:": workspace:~

npm ERR! A complete log of this run can be found in: npm ERR! /home/foo/.npm/_logs/2023-04-10T17_26_53_147Z-debug-0.log Error: Generator at prisma-pothos-types could not start:

/bin/sh: 1: prisma-pothos-types: not found

So something here is trying to run npm which is pretty much a no-no inside a pnpm-enabled repo. Assuming it tries to do something like "npx prisma-pothos-types", it should probably rather run "pnpx prisma-pothos-types". I wouldn't mind looking at this, but am a bit baffled at where this happens (could it be via prisma generate?).

Note that the npm error is that it is reading the package.json which uses a pnpm specific feature.

Cauen commented 1 year ago

Hi, @larsivi

According to the error messages, it seems to be an unrelated problem with this generator. Have you installed the pothos prisma plugin?

After installation, please test that everything is working without including this generator in schema.prisma

If indeed the error is related to this generator, can you please share a minimal reproducible example?

larsivi commented 1 year ago

Hmm, you are right. I must have made some error earlier - this does not work without the pothos generators either. Sorry for the disturbance. I had just read from a different prisma issue that this was supposed to have been fixed there, and I didn't test it properly.

larsivi commented 1 year ago

For posterity, my initial mistake was that I had messed up the workspace setup, which was what caused the NPM stuff. However, after fixing that, the pothos plugins were still not found.

Looking at the @pothos examples, I noted that "generate": "prisma generate" was added to the scripts in package.json, and when I did that and ran "pnpm generate" rather than "pnpx prisma generate" it worked.

So in the end this is probably some inconsistency between pnpx and pnpm run, or perhaps out of scope of pnpx.

FWIW, changes to public-hoist-pattern wasn't necessary either.