Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Prisma deploy doesn't generate files on windows #2494

Closed
blocka opened this issue May 23, 2018 · 74 comments
Closed

Prisma deploy doesn't generate files on windows #2494

blocka opened this issue May 23, 2018 · 74 comments

Comments

@blocka
Copy link

blocka commented May 23, 2018

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

@marktani
Copy link
Contributor

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!

@yocheved
Copy link

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

@marktani
Copy link
Contributor

The problem is that .graphqlconfig.yml is not correctly configured 🙂

@yocheved
Copy link

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
Copy link

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.

@nikolasburk
Copy link
Member

nikolasburk commented May 23, 2018

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.

@yocheved
Copy link

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

@nikolasburk
Copy link
Member

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

@nikolasburk nikolasburk reopened this May 23, 2018
@marktani
Copy link
Contributor

@yocheved can you provide reproduction repositories for both cases? 🙂

@blocka
Copy link
Author

blocka commented May 23, 2018

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

@marktani
Copy link
Contributor

marktani commented May 23, 2018

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

@blocka
Copy link
Author

blocka commented May 23, 2018

Sorry for the delay,
It is still an issue.

@gsancho
Copy link

gsancho commented May 24, 2018

i have the same problem :(

@PhilipBridges
Copy link

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?

@ntziolis
Copy link
Contributor

ntziolis commented May 25, 2018

@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

@marktani
Copy link
Contributor

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

@ntziolis
Copy link
Contributor

@marktani Was in the rpocess of updating my post

@marktani
Copy link
Contributor

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

@ntziolis
Copy link
Contributor

ntziolis commented May 25, 2018

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

@ntziolis
Copy link
Contributor

ntziolis commented May 25, 2018

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
Copy link
Contributor

ntziolis commented May 25, 2018

Basically im out of ideas. My initial report that I was able to create the file after removing the prepare lib was FALSE. All it did was remove the error message. still no prisma.ts though.

Here is is a step by step to understand what changes when:

  • yarn install
  • graphql codegen ==> no file gets created, and 'prepare' error is shown
  • rimraf node_modules\graphql-cli-prepare\
  • graphql codegen => file still does NOT get created, but error is gone

@ntziolis
Copy link
Contributor

ntziolis commented May 25, 2018

I have taken some time to summarize this issue as I think this are multiple:

  1. (solved) New way the code generation gets triggered
  2. (solved) Codegen has to be used instead of prepare, which was wrong in the old boilerplates
  3. (open) prisma deploy does not properly trigger running scripts (at least on windows)
  4. (open) While graphql get-schema' works when manually executed graphql codegen `command does NOT work on windows when manually executed

Summary
I think we can live with no 3 for a bit, but NOT with No 4 as this basically requires windows folks to stay below version 1.7.

@marktani
Copy link
Contributor

Thanks for the summary, @ntziolis. We will work on this issue soon! 🙂


One note, graphql codegen is tied to prisma-binding version 2.x, while graphql prepare is tied to prisma-binding version 1.5.x.

Neither is tied to the prisma version itself, so if you want to upgrade to prisma 1.7+, you can do so on Windows as well, if you use prisma-binding version 1.5.x and graphql prepare 🙂

@ntziolis
Copy link
Contributor

ntziolis commented May 25, 2018

Thank you for the workaround.

@abelovic
Copy link

abelovic commented Jun 6, 2018

When you create a release it should be published to npm at the same time as part of your deployment process always

@marktani
Copy link
Contributor

marktani commented Jun 6, 2018

Yes, we're setting up an automatic publishing flow as you suggested 🙂

@rohmanhm
Copy link
Contributor

I still get the error message, but everything worked well.

I'm on Windows 10

Here the error message

Romsy@ROMSY-PC MINGW64
$ prisma deploy
Deploying service `default` to stage `default` to server `default` 48ms
Service is already up to date.

post-deploy:
warning command prepare both exists in plugin pathsomewhere\node_modules\graphql-cli-prepare and is shipped with the graphql-cli.
The plugin is being ignored.

Running graphql get-schema --project database...
project database - No changes
Running graphql get-schema --project database √
warning command prepare both exists in plugin pathsomewhere\node_modules\graphql-cli-prepare and is shipped with the graphql-cli.
The plugin is being ignored.

Running graphql codegen √

Here's my dep and devDep

  "dependencies": {
    "bcryptjs": "2.4.3",
    "graphql-yoga": "1.14.10",
    "jsonwebtoken": "8.3.0",
    "prisma-binding": "2.1.0"
  },
  "devDependencies": {
    "@types/bcryptjs": "2.4.1",
    "dotenv-cli": "1.4.0",
    "graphql-cli": "2.16.3",
    "nodemon": "1.17.5",
    "npm-run-all": "4.1.3",
    "prisma": "1.10.2",
    "rimraf": "2.6.2",
    "ts-node": "6.2.0",
    "typescript": "2.9.2"
  }

@yocheved
Copy link

@rohmanhm I also get that warning but it everything still works as expected

@konsumer
Copy link

konsumer commented Sep 6, 2018

I am still getting this with prisma 1.15.3 & graphql-cli 2.16.5 on OSX.

If I run PRISMA_ENDPOINT=http://localhost:4466 prisma deploy:

Deploying service `default` to stage `default` to server `local` 45ms
Service is already up to date.

post-deploy:
Running graphql get-schema --project database ✔

but server/api/database/generated.graphql isn't created.

If I run PRISMA_ENDPOINT=http://localhost:4466 graphql get-schema --project database

it generates it, fine.

.graphqlconfig.yml:

projects:
  app:
    schemaPath: server/api/schema/*.graphql
    extensions:
      endpoints:
        default: http://localhost:8000
  
  database:
    schemaPath: server/api/database/generated.graphql
    extensions:
      prisma: server/api/database/prisma.yml

server/api/database/prisma.yml:

endpoint: ${env:PRISMA_ENDPOINT}

datamodel: datamodel.graphql

seed:
  import: seed.graphql

hooks:
  post-deploy:
    - graphql get-schema --project database

@konsumer
Copy link

konsumer commented Sep 6, 2018

I managed to get it to work right by installing graphql "^0.13.0", instead of "^0.14.0".

@juancamiloqhz
Copy link

I managed to get it to work right by installing graphql "^0.13.0", instead of "^0.14.0".

Same for me. It works when I change the grapqhl version

@JensMadsen
Copy link

cannot get it to work even when downgrading graphql version as suggested

@pitops
Copy link

pitops commented Nov 6, 2018

i can confirm version 0.14.0 is not working to generate schema

@steph4nc
Copy link

steph4nc commented Nov 9, 2018

I also have the same problem, running on "graphql": "^0.13.2"

@pitops
Copy link

pitops commented Nov 9, 2018

I think i found a working solution (works with graphql: v14)

add this to your prisma.yml file

hooks:
  post-deploy:
    - graphql get-schema -p prisma
    - prisma generate
generate:
  - generator: graphql-schema
    output: ./src/generated/

@saifali96
Copy link

saifali96 commented Nov 10, 2018

I'm following the GraphQL tutorial from How To GraphQL and when I run prisma deploy on Windows, it doesn't generate the schema.

Output as follows:

Deploying service XXX-node to stage dev to server prisma-eu1 186ms
Service is already up to date.
post-deploy:
spawnSync graphql ENOENT
Running graphql get-schema --project db ×

I tried to change the post deploy code in config file in different ways but nothing seemed to work. Even simple echo messages are not being executed. I also tried adding a silent command to create a file but even that wasn't executed.

My observation is that this is a scripting issue and the arguments are not properly passed to powershell or cmd for execution.

Workaround is to run graphql get-schema --project db yourself in a terminal, which does the job.

My environment and version is latest, created and fetched/installed today.

@beeplin
Copy link

beeplin commented Nov 11, 2018

I get this issue too.

@rohmanhm
Copy link
Contributor

@saifali96 Have you tried with git bash on windows? I'm using git bash on windows. Everything works well, except it just throws the error messages.

prisma/prisma#2494 (comment)

@saifali96
Copy link

@rohmanhm nice idea, I changed my laptop and almost forgot about mingw. Thanks I'll use that.
But given the number of comments on this issue, I think this should be addressed in the next release.

Cheers!

@SeanK1191
Copy link

Did using git bash work for you @saifali96? I'm having the same problem, thought I had it working but now I'm just getting same output as you had in cmd and git bash.

@saifali96
Copy link

@SeanK1191 no. Unfortunately it doesn't work with git bash either.

For now, only workaround is to run the command yourself in the terminal.

@divyenduz
Copy link
Contributor

Can any one of you please create a new issue for this? It is easily possible for newer comments on closed issues to be missed 🙏

Thanks!

@SeanK1191
Copy link

@divyenduz I believe issue #3491 is the same or related to the issue mentioned here.

@saifali96 I'm also doing the HowToGraphQL tutorial, gonna remove the post hook and use this npm script for now, hope it helps:

"prisma-deploy": "prisma deploy & graphql get-schema --project database"

@saifali96
Copy link

@SeanK1191 I tried using the above script in the prisma.yml file but it doesn't work. the post-deploy hook doesn't get executed at all.

My observation is npm-run above 4.x is broken on Windows envs.

#3491 should fix it.

@divyenduz
Copy link
Contributor

Thanks all for reporting this, in the mean time we will downgrade npm-run shortly:- prisma/prisma#3517

@alfredringstad
Copy link

Until this is released, if you use yarn a workaround is to add this to your package.json:

"resolutions": {
  "npm-run": "4.1.2"
}

@divyenduz
Copy link
Contributor

This is already available in the latest beta, please install it via npm install -g prisma@beta

@Daniely2564
Copy link

Daniely2564 commented Dec 4, 2018

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?

you are amazing.

@superhawk610
Copy link

Changing graphql get-schema --project database to just graphql get-schema fixed it for me, though I'm very new to graph-ql still so it could just be due to an improperly configured project.

@ShadyMohammed
Copy link

I have the same issue. I'm working on ubuntu 18.10

The output is:
post-deploy:
Running graphql get-schema ✔
Running graphql codegen ✔

but the generated file is never updated.

I have followed all the steps in this thread.

@smithmanny
Copy link

If anybody is still having trouble adding .graphql to the end of your output worked for me.

endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
# secret: ${env:PRISMA_SECRET}

generate:
  - generator: graphql-schema
    output: src/generated/prisma-client.graphql

hooks:
  post-deploy:
    - prisma generate

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

No branches or pull requests