Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-schema doesn't update the generated schema when called in post-deploy hook of prisma.yml #354

Closed
carstenbaumhoegger opened this issue Nov 8, 2018 · 10 comments
Assignees

Comments

@carstenbaumhoegger
Copy link

Describe the bug
As I updated to [email protected] 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:

  1. Change something in datamodel.graphql
  2. re-deploy prisma
  3. 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
@carstenbaumhoegger carstenbaumhoegger changed the title get-schema doesn't update the generated schema when called in post-deploy hook of prisma.yml get-schema doesn't update the generated schema when called in post-deploy hook of prisma.yml Nov 8, 2018
@Siyfion
Copy link

Siyfion commented Nov 13, 2018

I am also suffering from this issue!

@nikolasburk
Copy link
Contributor

nikolasburk commented Nov 13, 2018

As a workaround, you can generate prisma.graphql using the prisma generate command:

  1. Add the following code to your prisma.yml:
    generate:
       - generator: graphql-schema
         output: ./generated/
  2. Run prisma generate (The prisma.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).
  3. To automatically update prisma.graphql after prisma deploy is ran, you need to configure a post-deploy hook in prisma.yml:
    hooks:
      post-deploy:
        - prisma generate

@maticzav maticzav self-assigned this Nov 14, 2018
@maticzav
Copy link
Contributor

@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. 🙂

@baninaveen
Copy link

I encounter same issue

@carstenbaumhoegger
Copy link
Author

carstenbaumhoegger commented Nov 28, 2018

@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

@pixelbacon
Copy link

pixelbacon commented Dec 4, 2018

@maticzav OSX, same issue

  • OS: macOS Mojave
  • node:10.9.0
  • yarn:1.12.3
  • prisma:^1.21.1
  • graphql-cli:^2.17.0
  1. Running graphql get-schema --project db generates proper src/generated/prisma.graphql.
  2. Running prisma deploy says both steps completed w/ success but the src/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"
  }
}

@pixelbacon
Copy link

pixelbacon commented Dec 4, 2018

Further reading...

npm ls | grep graphql-cli

├─┬ [email protected]
│ ├─┬ [email protected]
npm ERR! peer dep missing: graphql@^0.13.1, required by [email protected]
npm ERR! peer dep missing: graphql@^0.13.2, required by [email protected]
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by [email protected]
npm ERR! extraneous: [email protected] /xxx/node_modules/node-pre-gyp
npm ERR! extraneous: [email protected] /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 [email protected]
npm ERR! extraneous: [email protected] /xxx/dev/veed-backend/node_modules/graphql-static-binding/node_modules/graphql
npm ERR! extraneous: [email protected] /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/[email protected]
npm ERR! extraneous: [email protected] /xxx/dev/veed-backend/node_modules/@kbrandwijk/swagger-to-graphql/node_modules/graphql
npm ERR! peer dep missing: graphql@^0.13.1, required by [email protected]
npm ERR! peer dep missing: graphql@^0.13.2, required by [email protected]
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by [email protected]
npm ERR! peer dep missing: graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0, required by [email protected]
npm ERR! peer dep missing: [email protected] - 0.13.x, required by [email protected]
npm ERR! peer dep missing: [email protected] - 0.13.x, required by [email protected]
npm ERR! peer dep missing: [email protected] - 0.13.x, required by [email protected]
npm ERR! peer dep missing: [email protected] - 0.13.x, required by [email protected]
npm ERR! peer dep missing: [email protected] - 0.13.x, required by [email protected]
npm ERR! peer dep missing: graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0, required by [email protected]
npm ERR! peer dep missing: graphql@^0.13.1, required by [email protected]
npm ERR! peer dep missing: graphql@^0.13.2, required by [email protected]
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by [email protected]
npm ERR! peer dep missing: graphql@^0.13.1, required by [email protected]
npm ERR! peer dep missing: graphql@^0.13.2, required by [email protected]
npm ERR! peer dep missing: graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0, required by [email protected]

@pixelbacon
Copy link

pixelbacon commented Dec 4, 2018

@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

@ardatan ardatan closed this as completed Oct 28, 2019
Repository owner deleted a comment from ardatan Oct 29, 2019
@Urigo
Copy link
Owner

Urigo commented Oct 29, 2019

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

@Urigo
Copy link
Owner

Urigo commented Oct 29, 2019

I've posted the wrong Discord link, this is the correct one: https://discord.gg/xud7bH9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants