Current behavior
If you delete the generated files (prisma.graphql
and prisma.ts
under src
) prisma
will fail to operate as expected.
Reproduction
Delete the files mentioned in the current behavior and then run prisma deploy
.
Expected behavior?
If the generated files does not exist they should be regenerated.
I've had similar issue with prisma.graphql
not regenerating (I suspect after upgrade to 1.7).
Adding post-deploy hook to database/prisma.yml
helped to solve the issue (though I'm not using typescript):
hooks:
post-deploy:
- graphql get-schema --project prisma
Thanks @dsenkus, if you also need to generate GraphQL Bindings, you can add graphql prepare
:
hooks:
post-deploy:
- graphql get-schema --project prisma
- graphql prepare
@marktani this doesn't work for me. I've been following this tutorial and it originally generated the prisma.graphql
, but then when I updated the datamodel and tried to run prisma deploy
again, it didn't update the prisma.graphql
file. So i tried deleting it and rerunning the command multiple times and it doesn't work. I also tried adding the post-deploy hooks to database/prisma.yml
and I see nothing.
if I try to run prisma deploy
, it keeps saying it's already up to date. But I literally have no prisma.graphql
file?...
Deploying service `hackernews-node` to stage `dev` to server `prisma-us1` 130ms
Service is already up to date.
Thanks a lot for bringing this up, @iam-peekay!
I believe this to be related to your graphql-cli
, prisma
and prisma-binding
versions. Can you share the output for
prisma version
graphql -v
What prisma-binding
version are you using?
It looks like the tutorial you linked to is referring to prisma-binding
version 1.x, which works with graphql prepare
.
With prisma-binding
2.x, graphql prepare
doesn't work anymore and graphql codegen
needs to be used instead. This requires changes to .graphqlconfig.yml
that are not covered in the tutorial as far as I can see.
Lastly, the post deployment hooks in prisma.yml
are needed for prisma
versions >= 1.7.
Hi @marktani
I'm experiencing this issue as well.
I have updated everything to latest:
prisma 1.9.0
prisma-binding 2.0.2
graphql-yoga 1.14.7
graphql-cli 2.16.3
prisma.yml:
hooks:
post-deploy:
- graphql get-schema --project prisma
- graphql codegen
Above, you wrote:
This requires changes to .graphqlconfig.yml
My .graphqlconfig.yml:
projects:
app:
schemaPath: src/schema.graphql
extensions:
endpoints:
default: 'http://localhost:4000'
database:
schemaPath: src/generated/prisma.graphql
extensions:
prisma: database/prisma.yml
endpoints:
dev:
url: 'http://192.168.99.100:4466/icrumz-v2-server/dev'
headers:
Authorization: Bearer ${env:GQL_AUTH_TOKEN}
prepare-bundle: src/generated/database.graphql
Do you see anything here that needs to be updated?
I think I have it working :-)
Based on the advanced-boilerplate prisma.yml I changed:
hooks:
post-deploy:
- graphql get-schema --project prisma
to
hooks:
post-deploy:
- graphql get-schema --project database
Based on graphql-cli Usage I changed:
hooks:
post-deploy:
...
- graphql codegen
to
hooks:
post-deploy:
- ...
- graphql prepare
Now generated/database.graphql
and generated/prisma.graphql
are created and updated on deploy when there are schema changes.
So, it's all good now! 馃帀
@gihrig It's working like a charm! Thanks
Great you got it to work!
Let me clarify a couple of things around graphql prepare
and graphql codegen
馃檪
graphql
CLI before and including version 2.15.0
, you can use prisma-binding
version 1.x
and graphql prepare
together, as described in your comment.graphql
CLI since version 2.16.0
, you can use prisma-binding
version 2.x
and graphql codegen
together, which requires some changes to .graphqlconfig.yml
:projects:
prisma:
schemaPath: prisma.graphql
extensions:
prisma: prisma.yml
codegen:
- generator: prisma-binding
language: typescript
output:
binding: prisma.ts
graphql codegen
will call the binary prisma-binding
in this case, which is searched for in local node_modules
and global npm binaries.
So, if you want to run graphql codegen
as a post-deployment hook, verify that you have the versions mentioned above and these hooks:
hooks:
post-deploy:
- graphql get-schema --project prisma
- graphql codegen
Note that --project prisma
refers to the prisma:
key in .graphqlconfig.yml
under the projects:
key. If you have a different project name there, change the --project
argument accordingly.
Most helpful comment
I think I have it working :-)
Based on the advanced-boilerplate prisma.yml I changed:
to
Based on graphql-cli Usage I changed:
to
Now
generated/database.graphql
andgenerated/prisma.graphql
are created and updated on deploy when there are schema changes.So, it's all good now! 馃帀