Skip to content

prisma-korea/prisma-nexus-apollo-boilerplate

Repository files navigation

prisma-nexus-apollo-boilerplate

CI codecov

Boilerplate for typescript apollo server using prisma and nexus (AKA Prisma 2).

Specification

Setup environment

  1. cp ./dotenv/test.env ./dotenv/.env
  2. Include DATABASE_URL
    DATABASE_URL="postgresql://<user>:<password>@<url>:5432/postgres?schema=<scheme>"
    

    Note that you should change appropriate values in user, password, url, scheme fields. Or you can even use other database. More about connection urls

  3. Running yarn start or yarn dev will load env from dotenv/.env.

Generate Prisma Client and Nexus

yarn generate

Migration

Init migration

  1. Change models in schema.prisma.

    Note that prisma/migrations dir is included in .gitignore in this repo but it should not be ignored in production.

  2. Run migration script.

    Note that this should be targeting the production database. Locally, you can just run yarn db-push.

    yarn migrate
    
  3. Deploy migration to production.

    Note you may want to run yarn migrate:dev beforhand to test your migration.

    yarn migrate:deploy
    

Create test user

~ createuser --interactive --pwprompt
Enter name of role to add: test
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) y

About

Typescript apollo server using Prisma

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published