prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Prisma deploy doesn't generate files on windows

Open blocka opened this issue 8 years ago • 74 comments

Bug Report

Current behavior prisma deploy is not generating files

Reproduction

  1. install typescript-basic boilerplate
  2. delete generated files
  3. prisma deploy

Expected behavior? Should see generated files again

blocka avatar May 23 '18 08:05 blocka

Thanks for the bug report!

It looks like the problem is that prisma-binding has been upgraded to 2.x, but graphql prepare is still used instead of graphql codegen.

We'll update this soon!

marktani avatar May 23 '18 08:05 marktani

The latest boilerplate is using graphql codegen and it's still not generating files. I have tried this with prisma-binding still on version 1.5.19 and graphql prepare and it still doesnt work. Versions: prisma/1.8.3 (windows-x64) node-v8.11.2

yocheved avatar May 23 '18 09:05 yocheved

The problem is that .graphqlconfig.yml is not correctly configured :slightly_smiling_face:

marktani avatar May 23 '18 09:05 marktani

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

What is incorrect in there? Is there something I can change that will make this work?

yocheved avatar May 23 '18 09:05 yocheved

To clarify, when I run prisma deploy it does show this outcome

post-deploy:
Running graphql get-schema --project database √
Running graphql prepare √

but no files are generated. If I run those commands each on their own in the cmd prompt, that does generate the files.

yocheved avatar May 23 '18 09:05 yocheved

Sorry for the confusion, the code generation for prisma-binding 2.0 works slightly differently as it's not using the graphql prepare but the new graphql codegen command instead.

You basically need to update your prisma.yml and the .graphqlconfig.yml:

prisma.yml

# ... other properties

hooks:
  post-deploy:
    - graphql get-schema
    - graphql codegen

.graphqlconfig.yml

projects:
  myapp:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: prisma/prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/prisma.ts

Let me know if you have any further questions 🙌

You can also find more info in the docs here.

nikolasburk avatar May 23 '18 14:05 nikolasburk

@nikolasburk I'm using prisma-binding version 1.5.19 with graphql prepare in one project and prisma-binding version 2.0.1 with graphql codegen in another place and am getting the same results for both projects. The hooks run after prisma deploy but do not generate any files or changes unless I run them manually. I believe this is a windows issue because other people using linux have told me that this works for them.

yocheved avatar May 23 '18 14:05 yocheved

Hmm, I see. In that case I'm reopening the issue for someone to look into that specific case. Thanks @yocheved 🙏

nikolasburk avatar May 23 '18 15:05 nikolasburk

@yocheved can you provide reproduction repositories for both cases? :slightly_smiling_face:

marktani avatar May 23 '18 15:05 marktani

I was able to reproduce this directly from the typescript-basic boilerplate.

blocka avatar May 23 '18 15:05 blocka

Yes @blocka, I also was able to reproduce, but we adjusted the typescript-basic boilerplate since you reported the error :slightly_smiling_face: Can you still reproduce the issue?

marktani avatar May 23 '18 15:05 marktani

Sorry for the delay, It is still an issue.

blocka avatar May 23 '18 18:05 blocka

i have the same problem :(

gsancho avatar May 24 '18 11:05 gsancho

I believe prisma deploy is not running graphql get-schema --project database properly. Or maybe it's not passing the users .env flags. But regardless, if I run prisma deploy then manually run graphql get-schema --project database --dotenv=myenvpath, it generates the file properly. So is this just a script error?

PhilipBridges avatar May 24 '18 15:05 PhilipBridges

@marktani This problem still persists after latest upgrades to boilerplate projects:

  • tried again yesterday evening
  • schema gets downloaded properly
  • bindings are reportedly created but that's not true, no file is written anywhere during bindings creation

Getting the following warnings warning command prepare both exists in plugin C:\project\node_modules\graphql-cli-prepare and is shipped with the graphql-cli.

Basically that leaves us not being able to migrate to 1.7+ right now.

.graphqlconfig:

projects:
  database:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: database/prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/prisma.ts

prisma.yml


# the full uri to the prisma endpoint
endpoint: ${env:PRISMA_ENDPOINT}

# the file path pointing to your data model
datamodel: datamodel.graphql

# to disable authentication uncomment below
secret: ${env:PRISMA_SECRET}

# seed your service with initial data
seed:
  import: ${env:PRISMA_SEED}

# Download the GraphQL schema of the Prisma API into
# `src/generated/prisma.graphql` (as specfied in `.graphqlconfig.yml`).
# Then generate the corresponding TypeScript definitions into
# `src/generated/prisma.ts` (also specfied in `.graphqlconfig.yml`)
# with `graphql codegen` .
hooks:
  post-deploy:
    - graphql get-schema --project database
    - graphql codegen --project database

folder structure: database/prisma.yml database/datamodel.graphql .graphqlconfig

ntziolis avatar May 25 '18 07:05 ntziolis

Thanks for your feedback @ntziolis! Can you share your .graphqlconfig.yml and the hooks from prisma.yml?

marktani avatar May 25 '18 08:05 marktani

@marktani Was in the rpocess of updating my post

ntziolis avatar May 25 '18 08:05 ntziolis

Does it work if you run graphql codegen directly from the command line, and not as a hook?

marktani avatar May 25 '18 08:05 marktani

Nope, same result reports success + warning. Even tried with specific project but same result: image

ntziolis avatar May 25 '18 08:05 ntziolis

The issue was as suggested graphql-cli-prepare, once i manually deleted the node module folder for this package creation of bindings ran smoothly ... sadly now other pieces break where graphql cli prepare was being used.

I will provide an update once I figure out how to remove the dep to graphql-cli-prepare

ntziolis avatar May 25 '18 08:05 ntziolis