I am using a generate nexus script, as suggested by @jasonkuhrt (see blog example), to make sure that the nexus-prisma types are available before starting the build step.
However, the build step on dokku and Heroku 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.
Locally (MacOS), everything builds without errors. Also, the deployment previously (before [email protected]) went through without problems.
Any ideas how this could be resolved?
So, I got this working by generating nexus-prisma into src/nexus-prisma.ts and nexus into src/nexus.ts, i.e. not into node_modules/@types/__nexus-typegen__nexus-prisma and node_modules/@types/__nexus-typegen__nexus-core
Not sure what the disadvantages of generation into src are.
Thanks for the updates @iherger! Are you committing the files? One disadvantage of src is cluttering workspace with derived data. Another is possibly more config needed to get TS picking up the types (tsconfig settings or import etc.). A third is that it makes the app incur boilerplate with the path configs that are needed.
I would love to understand better your scenario and why node_modules is not working. Could I possibly look at the project/deployment somehow? Or tell me how to repro more specifically? Thanks!
I did some experiments: it seems that the nexus and nexus-prisma generated files need to be committed for Heroku/dokku to build successfully with tsc. I did not find another way at the moment.
I mentioned earlier that this used to work with earlier versions of nexus-prisma. However, I may have committed the generated nexus-prisma file then as well, so this would not be different.
So I am now using a husky pre-commit hook to generate the nexus and nexus-prisma files. That way I am sure that I always have the latest files committed.
In addition, I noticed that zeit-now deployment fails if I generate into nexus/index.d.ts whereas it successfully builds if I generate into nexus.ts.
So the current setup is as follows:
husky pre-commit hook generates the nexus and nexus-prisma files on commitnexus-generated/nexus.ts and nexus-generated/nexus-prisma.ts @iherger where are you generating photon into?
@jasonkuhrt , photon is generated into the standard location node_modules/@generated/photon
BTW: I gave you access to the repo.
@iherger Ah thanks! Will check that out too later.
photon is generated into the standard location node_modules/@generated/photon
Ok, so that works at least. I guess the difference is that you cannot build the app without nexus generation, but you can without photon generation.
Hey @iherger could you DM me on prisma slack or link here which repo you shared. I can't seem to find any notification about it...
@iherger Have you tried https://devcenter.heroku.com/articles/nodejs-support#heroku-specific-build-steps
Looking at the Heroku buildpack output:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Installing dependencies
remote: Installing node modules (yarn.lock)
remote: yarn install v1.18.0
remote: [1/4] Resolving packages...
remote: [2/4] Fetching packages...
remote: [3/4] Linking dependencies...
remote: [4/4] Building fresh packages...
remote: Done in 2.67s.
remote:
remote: -----> Build
remote:
remote: -----> Pruning devDependencies
remote: yarn install v1.18.0
remote: [1/4] Resolving packages...
remote: [2/4] Fetching packages...
remote: [3/4] Linking dependencies...
remote: [4/4] Building fresh packages...
remote: warning Ignored scripts due to flag.
remote: Done in 0.48s.
remote:
remote: -----> Caching build
remote: - node_modules
I am surprised you are not having issues with @generated given the prune step.
@jasonkuhrt I sent you a DM on slack.
In the meantime, I have found out that the problem is based on the setting of NODE_ENV. It seems that nexus and nexus-prisma by default do not generate the files in a production environment, only in a development environment (or with NODE_ENV not set).
Adding the option shouldGenerateArtifacts: true to both nexusPrismaPlugin and makeSchema solves this issue.
Closing this. The followup issue is on Nexus side now. Thanks @iherger!
Hey @jasonkuhrt and @iherger, do you have any updates on this issue yet? I'm still seeing Property 'crud' does not exist on type 'ObjectDefinitionBlock<"Mutation"> when I try to deploy to heroku.
Here is my scripts code:
"scripts": {
"server": "ts-node src/index.ts",
"clean": "rm -rf dist",
"generate": "npm -s run generate:prisma && npm -s run generate:nexus",
"generate:prisma": "prisma generate",
"generate:nexus": "ts-node --transpile-only src/schema",
"dev": "ts-node-dev --no-notify --respawn --transpile-only src",
"playground": "graphql playground",
"prisma": "prisma",
"graphql": "graphql",
"build": "npm -s run clean && NEXUS_SHOULD_GENERATE_ARTIFACTS=true && npm -s run generate && tsc"
},
Most helpful comment
@jasonkuhrt I sent you a DM on slack.
In the meantime, I have found out that the problem is based on the setting of
NODE_ENV. It seems thatnexusandnexus-prismaby default do not generate the files in a production environment, only in a development environment (or withNODE_ENVnot set).Adding the option
shouldGenerateArtifacts: trueto bothnexusPrismaPluginandmakeSchemasolves this issue.