First of all: huge congratulations on the release of v0.4.1!
I changed my code according to your example, and it basically works fine!
The dev server starts perfectly fine with ts-node-dev -r dotenv/config --no-notify --respawn --transpileOnly ./src
However, the build script (rm -rf dist/ && tsc && cp src/types.ts dist/src/) fails with following errors:
node_modules/nexus-prisma/dist/dmmf/DMMFClass.d.ts:1:23 - error TS2688: Cannot find type definition file for 'global'.
1 /// <reference types="global" />
~~~~~~
node_modules/nexus-prisma/dist/dmmf/DMMFClass.d.ts:10:23 - error TS2304: Cannot find name 'Index'.
10 outputTypesIndex: Index<DMMF.OutputType>;
~~~~~
node_modules/nexus-prisma/dist/dmmf/DMMFClass.d.ts:12:22 - error TS2304: Cannot find name 'Index'.
12 inputTypesIndex: Index<DMMF.InputType>;
~~~~~
node_modules/nexus-prisma/dist/dmmf/DMMFClass.d.ts:13:17 - error TS2304: Cannot find name 'Index'.
13 enumsIndex: Index<DMMF.Enum>;
~~~~~
node_modules/nexus-prisma/dist/dmmf/DMMFClass.d.ts:14:18 - error TS2304: Cannot find name 'Index'.
14 modelsIndex: Index<DMMF.Model>;
~~~~~
Able to reproduce in the example blog app. Note this issue not visible if "skipLibCheck": true, present in tsconfig.
Thanks. I set skipLibCheck to true and that error disappears indeed.
For building (on Dokku, also on zeit-now), there are still errors, though:
Property 'crud' does not exist on type 'OutputDefinitionBlock<"Mutation">'.
I assume this has got something to do with the nexus-prisma types (like t.model and t.crud) that are built when the GraphQL server is first run (like in your example).
So what additional step would need to be taken so that a clean build works fine? Would you create a script that just executes makeSchema, so that the correct types are generated?
I assume this has got something to do with the nexus-prisma types (like t.model and t.crud) that are built when the GraphQL server is first run (like in your example).
Correct!
So what additional step would need to be taken so that a clean build works fine? Would you create a script that just executes makeSchema, so that the correct types are generated?
Can you open a new issue about this. There are various things a user can do, but nothing constant nor simple enough yet. It is unrelated to this bug so let's move the conversation. Thanks so much for reporting this!
@iherger I've updated the example with how to structure your app to support a nexus:generate step. Let me know if this unblocks your case.
Thanks, @jasonkuhrt ! I had come up with basically the same solution (I was putting the nexus generation step into postinstall (like prisma2 generate), though).
Locally, everything now works fine now.
However, I cannot deploy to my dokku installation (using Heroku build packs), this still fails with the errors
Property 'crud' does not exist on type 'OutputDefinitionBlock<"Query">'.
Property 'model' does not exist on type 'ObjectDefinitionBlock<"User">'.
even though the nexus generation script is executed just before.
Shouldn't the type generation be disabled anyway when deploying in prod? If you pass NODE_ENV=production to your node entry point all I/Os will be disabled (typegen + schema gen)
When you build on Heroku with tsc, then you need the type generation, otherwise the build fails.
Shouldn't the type generation be disabled anyway when deploying in prod?
No, because part of deploying in prod is building for prod. This is how heroku build packs work, and it is ok, we just need to realize that NODE_ENV may be production when building, and so cannot be the only mechanism available to control artifact generation.
This is why #455 exists. 馃寛
did anyone manage to get around this issue?
tried adding outputs: { typegen: path.join(process.cwd(), 'pages', 'api', 'index.ts') } but getting the same error
Most helpful comment
No, because part of
deploying in prodisbuilding for prod. This is how heroku build packs work, and it is ok, we just need to realize thatNODE_ENVmay beproductionwhen building, and so cannot be the only mechanism available to control artifact generation.This is why #455 exists. 馃寛