Prisma 1.30 + GraphQL Yoga + Typescript
-
Install prisma cli:
npm install -g prisma
-
Install docker
-
Launch Prisma and the connected database:
docker-compose up -d
Prisma is now connected to a local database and runs on
http://localhost:4466
-
Set your envars inside
config/dev.env
PRISMA_ENDPOINT=http://localhost:4466 PRISMA_SECRET=pi389xjam2b3pjsd0 JWT_SECRET=23oijdsm23809sdf
-
Deploy the Prisma datamodel:
prisma deploy -e config/.env.dev
This step generates the Prisma client automatically, also you can generate it again by running
prisma generate
, and seeds the database with testing data, also you can seed whenever you want by runningyarn database:seed
Note: For more info about how to set up prisma with a new or existing database here
-
Install dependencies:
yarn
ornpm install
-
Run in local env:
yarn dev
ornpm run dev
-
Visit:
http://localhost:4000
You can access to your database by running prisma admin -e config/.env.dev
You can generate an access token to use it at the playground by running prisma token -e config/.env.dev
Note: Remember you need to put your access token generated as a http header when you query using playground
{
"Authorization":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiY2p1ZWlxd2NpMDBreDA4NjFrbDhnYjc1cyIsInJvbGUiOiJBZG1pbiJ9LCJpYXQiOjE1NTUxMDM1NTYsImV4cCI6MTU1NTcwODM1Nn0.4Y3QdckBpyk9xZcJhQsZlzVPfWbGSnpivaFTHAwQ0PU"
}
- Basic sign up
- Basic login with user and password
- JWT Authentication
- Authentication Middleware
- Authorization Middleware based on roles (User, Admin and Super)
- Set of directives for input validations
- Limitation of graph depth