Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prisma: What's the workflow?

Just started using Prisma as a way to integrate GraphQL and MySQL into a new project I am working on. It's great, I love how simply it lays things out. I have a few questions which are bothering me though regarding the workflow to follow when developing with Prisma.

For example:

Yesterday I setup the basic Prisma and GraphQL server as per the tutorial. It all worked well. I only have a single type modelled in my datamodel.graphql.

This morning I wake up and start work on another type and add that to my datamodel.graphql. Docker is running, I update the index.js with resolvers to support the new Model and it's Querys/Mutations. However, when it comes to running the system using node ./index.js I get an error saying it isn't aware of the new Model. I suspect the Prisma schema hasn't been refreshed/updated so i run graphql get-schema --project prisma but it tells me that nothing has changed.

Obviously I'm missing something. I am not working with Prisma in a way it would like. Can anyone illuminate me as to the order of events which have to take place for things to run smoothly?

The tutorial is great for getting you up and running but I feel like it doesn't well introduce developers into the flow of using Prisma on a day-to-day continuous development cycle.

Any info/insight/links would be very useful.

Many thanks,

A

UPDATE

For anyone else who has become a little lost about the workflow. Take a look at the CLI reference. It's very useful for all Prisma related tasks (not necessarily all things to do with your GraphQL server). LINK

TL;DR:

You need to redeploy your prisma service each time the datamodel changes so that the generated prisma.graphql can be updated with new functionality to work with the DB. I ran prisma deploy and voila!

like image 539
A.Smith Avatar asked Jul 31 '18 10:07

A.Smith


1 Answers

You are missing the prisma deploy step.

You're confusing the data model (typically called datamodel.graphql) with the Prisma database schema (typically called prisma.graphql).

The data model is used by Prisma to automatically generate the Prisma database schema:

enter image description here

Please follow this gist to see the difference between the two in more detail: https://gist.github.com/nikolasburk/eef24cd0d907b4a3e073723054cf847d

like image 166
divyenduz Avatar answered Sep 18 '22 15:09

divyenduz