prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Post-deploy `graphql get-schema` doesn't generate files

Open niba opened this issue 8 years ago • 9 comments

I have configured my post-deploy hook to update my database schema automatically. Unfortunately, the files are not being generated. Here is my config:

endpoint: http://localhost:4466
datamodel: datamodel.graphql
hooks:
  post-deploy:
    - graphql get-schema -p prisma
seed:
  import: ./seed.graphql

and the output of prisma deploy

> prisma deploy Deploying service default to stage default to server local 111ms Service is already up to date.

post-deploy: Running graphql get-schema -p prisma √

As you can see logs show success but it's not true.

Running graphql get-schema -p prisma manually works and generates files

  • OS Windows 10
  • prisma/1.13.5 (windows-x64) node-v8.9.4
  • prisma server 1.13

niba avatar Aug 04 '18 21:08 niba

Can you share the .graphqlconfig.yml file, and your local and global versions of graphql-cli? 🙂

marktani avatar Aug 06 '18 08:08 marktani

Sure, the graphql config:

projects:
  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: http://localhost:4000
  prisma:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: prisma/prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/prisma.ts

and the graphql-cli version is 2.16.5 for global. I have only global version, haven't installed CLI in my project

niba avatar Aug 06 '18 09:08 niba

I followed the guide here https://www.prisma.io/docs/develop-prisma-service/service-configuration/data-model-knul/

Under one of the section

.graphqlconfig.yml

project:
  db:
    schemaPath: prisma.graphql
    extensions:
      prisma: prisma.yml

example was given, for the longest time I could not figure out why the schema file was not generating for me. It seems that the "project" heading has to be "projects"

ShunnyBunny avatar Sep 03 '18 07:09 ShunnyBunny

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 18 '18 07:10 stale[bot]

@niba did you find a solution? I ran into the same problem as you yesterday and haven't found a solution yet.

tzjoke avatar Dec 16 '18 13:12 tzjoke

@tzjoke nope, I decided to not use Prisma and graphql because Prisma doesn't support interface inheritance and unions and all of my issues that I reported have been closed by the stale bot

niba avatar Dec 17 '18 10:12 niba

I'm having this issue now. Prisma was working fine along with my post-deploy hook graphql get-schema -p prisma, but since yesterday it just doesn't update the generated file.

This is my .graphqlconfig.yml file:

projects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "http://localhost:4444"
  prisma:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: prisma.yml

And this is my prisma.yml:

endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
hooks:
  post-deploy:
    - graphql get-schema -p prisma

I haven't changed those files at all, nor have I changed my prisma version or anything similar.

evenmed avatar Oct 29 '19 14:10 evenmed

Alright I fixed it based on this answer: https://github.com/prisma/prisma/issues/3469#issuecomment-455955230

I had to change my prisma.yml to:

endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
generate:
  - generator: graphql-schema
    output: ./src/generated/
hooks:
  post-deploy:
    - graphql get-schema -p prisma
    - prisma generate

Still can't figure out why this error started happening without me changing my prismal or graphql versions, but I'm glad it's fixed now.

evenmed avatar Oct 29 '19 14:10 evenmed

In prisma 1.34, the solution shared by @evenmed will throw Error: output for generator graphql-schema should be a .graphql-file.

Replace output: ./src/generated/ with output: ./src/generated/prisma.graphql to avoid the error.

nsgrantham avatar Jul 04 '20 23:07 nsgrantham