nexus-plugin-prisma: Property 'model' does not exist on type 'ObjectDefinitionBlock<"User">'

Hi everyone, I’m using now to deploy a micro graphql server and while I had this repo working yesterday, something happened in the past day and I can’t figure out what is going on. Perhaps the easiest way to test is with my minimal example below.

https://github.com/CaptainChemist/zeit-now-prisma-2

Create a mysql database and then update the mysql string in the following repo to your database.

What I am now seeing when I run npm run dev from the home directory is this:

Error: api/src/index.ts(17,7): error TS2339: Property 'model' does not exist on type 'ObjectDefinitionBlock<"User">'.
api/src/index.ts(18,7): error TS2339: Property 'model' does not exist on type 'ObjectDefinitionBlock<"User">'.
api/src/index.ts(19,7): error TS2339: Property 'model' does not exist on type 'ObjectDefinitionBlock<"User">'.
api/src/index.ts(26,7): error TS2339: Property 'crud' does not exist on type 'ObjectDefinitionBlock<"Query">'.
api/src/index.ts(27,7): error TS2339: Property 'crud' does not exist on type 'ObjectDefinitionBlock<"Query">'.
api/src/index.ts(40,7): error TS2339: Property 'crud' does not exist on type 'ObjectDefinitionBlock<"Mutation">'.

It then says that my @generated/photon/runtime/prisma does not exist. This is after running prisma2 generate and I can see that I have files in the photon and nexus-prisma @generated folder.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Hey @seed-of-apricot, hoping to update those soon, thanks for mentioning.

Yeah I didn’t notice it, thank you for referring to the example anyways 😃

Hey @CaptainChemist, this should be working now. Update your deps. You can see a working example in this repo under /example

Ref https://github.com/prisma/nexus-prisma/issues/367#issuecomment-526921529.

I was able to fix this by transpiling and running the file that calls makeSchema with babel to avoid type-checking. This creates all the files in @generated/nexus-prisma that will add the model and crud methods. The typescript build passes after that.

You can create a script in package.json to transpile with babel and run the file that includes makeSchema before running tsc

I believe this is related to zeit’s typescript compilation logic as I am able to @now/node@0.11.1 with prisma2@2.0.0-preview-3.2, binary version: acd6dd8dcf027b84a94af26b36ded779f1f56b1d

Even though there is this warning, I am also able to run the application with the latest now a builder and the whole API is operations.

For now, the bug is confirmed and it is related to nexus prisma so I am going to transfer this issue.