Nexus-plugin-prisma: nexus-prisma-generate error

Created on 11 Feb 2019  Â·  4Comments  Â·  Source: graphql-nexus/nexus-plugin-prisma

Versions:
"nexus": "0.9.11"
"nexus-prisma": "0.2.0"
"prisma-client-lib": "1.26.4"

When I run prisma deploy I experience two different errors depending on how I have defined my hooks -> post-deploy in primsa.yml.

Scenario 1:

Here I have not wrapped the client and output path in double-quotes:

hooks:
  post-deploy:
    - prisma generate
    - npx nexus-prisma-generate --client=./src/generated/prisma-client --output=./src/generated/nexus-prisma

Terminal output:

Deploying service `default` to stage `default` to server `local` 53ms
Service is already up to date.

post-deploy:

Generating schema... 23ms

Running prisma generate...
Saving Prisma Client (TypeScript) at /Users/user/project/src/generated/prisma-client/
Running prisma generate ✔
npx: installed 85 in 4.658s
prisma_datamodel_1.Parser.create is not a function

Running npx nexus-prisma-generate --client=./src/generated/prisma-client --output=./src/generated/nexus-prisma ✖

Error: prisma_datamodel_1.Parser.create is not a function

The src/generated/prisma-client/ -path is generated correctly with index.ts and prisma-schema.ts however the src/generated/nexus-prisma/ -path is empty.

Scenario 2:

Here I have wrapped the client and output path in double-quotes:

hooks:
  post-deploy:
    - prisma generate
    - npx nexus-prisma-generate --client="./src/generated/prisma-client" --output="./src/generated/nexus-prisma"

Terminal output:

Deploying service `default` to stage `default` to server `local` 54ms
Service is already up to date.

post-deploy:

Generating schema... 20ms

Running prisma generate...
Saving Prisma Client (TypeScript) at /Users/user/project/src/generated/prisma-client/
Running prisma generate ✔
npx: installed 85 in 4.691s

Running npx nexus-prisma-generate --client="./src/generated/prisma-client" --output="./src/generated/nexus-prisma"...
ERROR: Cannot find --client path at /Users/user/project/"./src/generated/prisma-client"
Running npx nexus-prisma-generate --client="./src/generated/prisma-client" --output="./src/generated/nexus-prisma" ✖

Error: ERROR: Cannot find --client path at /Users/user/project/"./src/generated/prisma-client"

In this case only the src/generated/prisma-client/ is present and no src/generated/nexus-prisma/

communitgood-first-issue typbug

Most helpful comment

So it looks like the latest alpha version of prisma-datamodel is 1.28.0-alpha.8, which is the version that gets installed with nexus-prisma-generate. The compiled .js for alpha.8 of prisma-datamodel exports DefaultParser (instead of Parser) with the create() function used here:

https://github.com/prisma/nexus-prisma/blob/master/packages/nexus-prisma-generate/src/config.ts#L34

ref from dist/index.js ([email protected]):

var parser_1 = require("./datamodel/parser");
exports.DefaultParser = parser_1.default;

All 4 comments

Hey 👋,

Thanks for reporting that issue. That's something I have noticed recently.

One work-around, for now, is to use the following syntax (removing both the quotes and the = symbol):

npx nexus-prisma-generate --client ./src/generated/prisma-client --output ./src/generated/nexus-prisma

I have updated the README accordingly

@Weakky I get the same error with all variations of the args.

npx: installed 85 in 4.403s
prisma_datamodel_1.Parser.create is not a function

Running npx nexus-prisma-generate --client ./src/generated/prisma-client --output ./src/generated/nexus-prisma ✖

So it looks like the latest alpha version of prisma-datamodel is 1.28.0-alpha.8, which is the version that gets installed with nexus-prisma-generate. The compiled .js for alpha.8 of prisma-datamodel exports DefaultParser (instead of Parser) with the create() function used here:

https://github.com/prisma/nexus-prisma/blob/master/packages/nexus-prisma-generate/src/config.ts#L34

ref from dist/index.js ([email protected]):

var parser_1 = require("./datamodel/parser");
exports.DefaultParser = parser_1.default;

Fixed by #93 and released under 2.0.0. Thanks for the PR @brannon-darby!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sachaw picture sachaw  Â·  3Comments

outerlook picture outerlook  Â·  5Comments

franjohn21 picture franjohn21  Â·  4Comments

colinhacks picture colinhacks  Â·  5Comments

RAW4RMCS picture RAW4RMCS  Â·  3Comments