Skip to content

Development Mode

Step 1. Install the required node packages

Install node packages for initializing the database and running the API with:

$ yarn install

you should see an output similar to:

 Image link

Step 2. Configure passwords and database location then start postgres

Copy the example environment configuration files to dev.env and .pgpass and change the passwords and location of database. Note that the password in the .pgpass must match the POSTGRES_PASSWORD environment variable in dev.env.

cp config/dev.env.example config/dev.env
cp config/.pgpass.example config/.pgpass

Start up postgres in a docker container with docker-compose --env-file config/dev.env start postgres10

Stopping can be done with docker-compose --env-file config/dev.env stop postgres10

Inspect the output with docker-compose logs postgres10

The output of this may be long the first time, but you should see a line near the end when successfully created similar to:

 Image link

Now postgres should be running in a docker image called deepsea-ai-pg

Check-out the running process with:

$ docker ps 

you should see an output similar to the following (yours may be different if you have more docker containers running):

 Image link

Check-out the volume with:

$ docker volume ls 

you should see an output similar to the following:  Image link

Step 3. Initialize the database

Now that you have postgres ready, create the database and populate it with some data.

First, push the schema state to the database. This only needs to be done once, unless changes are made to the schema.

$ env-cmd -f config/dev.env yarn push

 Image link


If you see Error: P1001: Can't reach database server at localhost:5432 this may be because the database is not up yet. Wait a few seconds then try again.

Finally, load with some simple seed data. This will create a user called Admin and attach some data to that user.

$ env-cmd -f config/dev.env yarn seed

(optional) Browse the database using Prisma Studio

Prisma provides a nice user interface to see and modify the data called Prisma Studio. Launch with:

yarn studio

then open Prisma Studio at http://localhost:5555

You should a dialog that prompts you to open a model, e.g.

 Image link

This is useful to manually browse the tables and delete data.

Step 4. Start the GraphQL client app

Generate the prisma client manually with the build command. Note that this only needs to be run when changes to the prisma.schema are made.

$ yarn build 

which should create the client and report completion, e.g.:

 Image link

There is now a /node_modules/@prisma/client which can be imported and used in the code. Note that under-the-hood this is running prisma generate which can also watch for changes in the primsa.schema file by adding the --watch command, e.g. prisma generate --watch.

Let's run the app in development mode now and open at http://localhost:4000/graphql

env-cmd -f config/dev.env yarn dev

That's it!

Check-out the example graphql queries and mutations to explore in the playground.

Deployment Notes

References - Prisma Deployment Docs