get-schema doesn't update the generated schema when called in post-deploy hook of prisma.yml
carstenbaumhoegger opened this issue · comments
Describe the bug
As I updated to prisma@1.20
today I noticed a strange behaviour of graphql get-schema
.
I haven't touched my prisma.yml
for months but suddenly today after some changes in datamodel.graphql
, the generated files remained unchanged after running graphql get-schema
in prisma.yml
post-deploy
.
When I run graphql get-schema
from my command line it notices the changes and generates the new schema files as expected.
To Reproduce
Steps to reproduce the behavior:
- Change something in
datamodel.graphql
- re-deploy prisma
- See, that the schema files in
src/generated
remain untouched
Expected behavior
The schema files get updated accordingly to the changes in the datamodel.
Versions (please complete the following information):
- OS:
macOS Mojave
graphql-cli
:2.17.0
prisma
:1.20.0
node
:10.10.0
I am also suffering from this issue!
As a workaround, you can generate prisma.graphql
using the prisma generate
command:
- Add the following code to your
prisma.yml
:generate: - generator: graphql-schema output: ./generated/
- Run
prisma generate
(Theprisma.graphql
will now be generated in the./generated
folder. It's currently not possible to specify a different name for that file, see this GitHub issue). - To automatically update
prisma.graphql
afterprisma deploy
is ran, you need to configure apost-deploy
hook inprisma.yml
:hooks: post-deploy: - prisma generate
@carstenbaumhoegger could you verify that this is not the same issue as prisma/prisma#3491? This would help a lot with navigation of the problem. 🙂
I encounter same issue
@nikolasburk thanks for posting the workaround!
Unfortunately when I modify my prisma.yml
and run this, I get Relation type mismatch.
as error.
@maticzav I'm working on macOS and can't reproduce this issue
@maticzav OSX, same issue
OS
:macOS Mojave
node
:10.9.0
yarn
:1.12.3
prisma
:^1.21.1
graphql-cli
:^2.17.0
- Running
graphql get-schema --project db
generates propersrc/generated/prisma.graphql
. - Running
prisma deploy
says both steps completed w/ success but thesrc/generated/prisma.graphql
does appear.
.graphqlconfig.yml
projects:
app:
schemaPath: src/schema.graphql
extensions:
endpoints:
default: http://localhost:4000
db:
schemaPath: src/generated/prisma.graphql
extensions:
prisma: database/prisma.yml
prepare-binding:
output: src/generated/prisma.ts
generator: prisma-ts
database/prisma.yml
secret: ${env:PRISMA_SECRET}
endpoint: ${env:PRISMA_ENDPOINT}
datamodel:
- types.graphql
- enums.graphql
hooks:
post-deploy:
- graphql get-schema --project db
- graphql prepare
package.json
{
"name": "demo-app",
"scripts": {
"start": "dotenv -- nodemon -e ts,graphql -x ts-node src/index.ts",
"dev": "npm-run-all --parallel start playground",
"debug": "dotenv -- nodemon -e ts,graphql -x ts-node --inspect src/index.ts",
"playground": "graphql playground",
"build": "rimraf dist && tsc",
"prisma": "dotenv -- prisma",
"db:seed": "dotenv -- ts-node src/seed.ts",
"db:up": "docker-compose up -d",
"db:down": "docker-compose down",
"db:stop": "docker-compose stop"
},
"dependencies": {
"@types/cors": "^2.8.4",
"@types/jsonwebtoken": "^8.3.0",
"@types/lodash": "^4.14.118",
"@types/moment": "^2.13.0",
"@types/node": "^10.12.11",
"apollo-cache-inmemory": "^1.3.11",
"apollo-cache-persist": "^0.1.1",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"debug": "^4.1.0",
"dotenv-cli": "^1.4.0",
"express-jwt": "^5.3.1",
"graphql-middleware-forward-binding": "^1.3.2",
"graphql-shield": "^4.1.0",
"graphql-yoga": "^1.16.7",
"jsonwebtoken": "^8.3.0",
"jwks-rsa": "^1.3.0",
"moment": "^2.22.2",
"nodemon": "^1.18.6",
"prisma-binding": "^2.2.8",
"ts-lint": "^4.5.1",
"ts-node": "^7.0.1",
"typescript": "^3.1.6"
},
"devDependencies": {
"@types/graphql": "^14.0.3",
"graphql-cli": "^2.17.0",
"npm-run-all": "^4.1.5",
"prisma": "^1.21.1"
}
}
Further reading...
npm ls | grep graphql-cli
├─┬ graphql-cli@2.17.0
│ ├─┬ graphql-cli-prepare@1.4.19
npm ERR! peer dep missing: graphql@^0.13.1, required by apollo-upload-server@5.0.0
npm ERR! peer dep missing: graphql@^0.13.2, required by graphql-middleware@1.7.7
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by graphql-subscriptions@0.5.8
npm ERR! extraneous: node-pre-gyp@0.10.3 /xxx/node_modules/node-pre-gyp
npm ERR! extraneous: graphql@0.13.2 /xxx/dev/veed-backend/node_modules/apollo-codegen/node_modules/graphql-config/node_modules/graphql-import/node_modules/graphql
npm ERR! peer dep missing: graphql@^0.11.0 || ^0.12.0 || ^0.13.0, required by graphql-static-binding@0.9.3
npm ERR! extraneous: graphql@0.13.2 /xxx/dev/veed-backend/node_modules/graphql-static-binding/node_modules/graphql
npm ERR! extraneous: graphql@0.13.2 /xxx/dev/veed-backend/node_modules/graphql-config/node_modules/graphql
npm ERR! peer dep missing: graphql@^0.12.0 || ^0.13.0, required by @kbrandwijk/swagger-to-graphql@2.4.3
npm ERR! extraneous: graphql@0.13.2 /xxx/dev/veed-backend/node_modules/@kbrandwijk/swagger-to-graphql/node_modules/graphql
npm ERR! peer dep missing: graphql@^0.13.1, required by apollo-upload-server@5.0.0
npm ERR! peer dep missing: graphql@^0.13.2, required by graphql-middleware@1.7.7
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by graphql-subscriptions@0.5.8
npm ERR! peer dep missing: graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0, required by apollo-server-core@1.4.0
npm ERR! peer dep missing: graphql@0.10.x - 0.13.x, required by apollo-cache-control@0.1.1
npm ERR! peer dep missing: graphql@0.10.x - 0.13.x, required by apollo-tracing@0.1.4
npm ERR! peer dep missing: graphql@0.10.x - 0.13.x, required by graphql-extensions@0.0.10
npm ERR! peer dep missing: graphql@0.10.x - 0.13.x, required by graphql-extensions@0.0.10
npm ERR! peer dep missing: graphql@0.10.x - 0.13.x, required by graphql-extensions@0.0.10
npm ERR! peer dep missing: graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0, required by apollo-server-core@1.4.0
npm ERR! peer dep missing: graphql@^0.13.1, required by apollo-upload-server@5.0.0
npm ERR! peer dep missing: graphql@^0.13.2, required by graphql-middleware@1.7.7
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by graphql-subscriptions@0.5.8
npm ERR! peer dep missing: graphql@^0.13.1, required by apollo-upload-server@5.0.0
npm ERR! peer dep missing: graphql@^0.13.2, required by graphql-middleware@1.7.7
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by graphql-subscriptions@0.5.8
@maticzav @carstenbaumhoegger
Working. May have been an upgrade issue.
package.json
as seen at graphql-boilerplates/node-graphql-server#211
{
...
"resolutions": {
"graphql": "^0.13.0",
"**/graphql": "^0.13.0"
}
}
prisma.yml
secret: ${env:PRISMA_SECRET}
endpoint: ${env:PRISMA_ENDPOINT}
datamodel:
- types.graphql
- enums.graphql
hooks:
post-deploy:
- graphql get-schema --project db
- graphql codegen
.graphqlconfig.yml
projects:
app:
schemaPath: src/schema.graphql
extensions:
endpoints:
default: http://localhost:4000
db:
schemaPath: src/generated/prisma.graphql
extensions:
prisma: database/prisma.yml
codegen:
- generator: prisma-binding
language: typescript
output:
binding: src/generated/prisma.ts
We've just released a new alpha version channel for GraphQL CLI - 4.0.0-alpha.XXX
!
We've changed the get-schema
command to use GraphQL Code Generator plugin of GraphQL CLI with the Codegen's schema-ast
plugin.
Could you please test it out with your Prisma setup and let us know if the new structure solves your issue?
Checkout new instructions in the migration guide and let us know your feedback during that alpha period!
Feel free to contact us by opening a new issue or joining our Discord channel;
https://discord.gg/xud7bH
I've posted the wrong Discord link, this is the correct one: https://discord.gg/xud7bH9