Skip to content

🚀 Minimalist boilerplate for super fast Graphql ⭐Run Graphql Playground in your local environment in less than a minute (w/ docker-compose).

License

Notifications You must be signed in to change notification settings

microenv/graphql-prisma-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graphql Prisma2 Boilerplate

A great boilerplate to start your new graphql project.

Development Setup

yarn install
yarn local:db:up

Wait until database is ready.

yarn local:migrate:up
yarn local
  • yarn install - Install yarn dependencies
  • yarn local:db:up - Create a new database (with docker-compose)
  • yarn local:migrate:up - Send migrations to database (Create schema in the database)
  • yarn local - Run local server // @TODO ~ put this inside docker compose with volume and nodemon
  • yarn uninstall - Remove docker containers (then you can safely remove this folder)

Example Queries

You can see a list of test queries to execute on graphql playground.

See Example Queries

Tech Stack

  • Typescript
  • Nexus (nexus-future)
  • Docker compose - Right now it's only creating a new database // @TODO ~ put this server inside a container and create a volume

System Requirements

  • Node
  • Yarn (or npm)
  • Docker compose
  • A developer (did you get it?)

Environment Variables

  • NODE_ENV=local
  • MASTERKEY=localmasterkey
  • PORT=4001
  • DB_URL=mysql://prisma:prisma@localhost:3310/workouts

@TODO ~ If you define a masterkey, then you need to send it in the header of all requests to this graphql server. More details below on Masterkey Authentication.

Manual Hooks

Somethings are not automatic. Here is what you need to do when you do what you do.

When you... Do this!
Change file: prisma/schema.prisma Run yarn local:migrate:save && yarn local:migrate:up
Change file: local.yml Run yarn local:db:up
  • yarn local:migrate:save - Update the folder prisma/migrations with the new schema definition on schema.prisma (prisma2 migrate save --experimental)
  • yarn local:migrate:up - Sync database with the newly created migrations (prisma2 migrate up --experimental)
  • yarn local:db:up - Roda o banco de dados local (via docker-compose)

Masterkey Authentication

@TODO ~ Not implemented yet.

If you define a MASTERKEY env variable, then this string must be send to every API call.

Header:

X-Masterkey: XXXXXXX

The masterkey config is located at config/*.env.

Tags

This project comes with a default schema with "tags". This allows you to immediately test your API and maybe you even like the initial schema and start building your software with tags...

A Todo may have as many tags as the client wants.

When you query todos(tags:["tag1","tag2"]) { ... } you need to send an array with tags. The todos must be related to all the tags you send (but it may have more).

If you pass an empty tags array, then all todos are returned.

@TODO

  • Steps to deploy in production
  • Add seed todos

About

🚀 Minimalist boilerplate for super fast Graphql ⭐Run Graphql Playground in your local environment in less than a minute (w/ docker-compose).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published