0.0.6 • Published 5 years ago
graphql-fleetgrid-com v0.0.6
README.md
Clone project and install:
$ git clone git@gitlab.com:fleetgrid/fleetgrid-graphql.git
$ cd fleetgrid-graphql
$ npm i
Run the project locally (outside of EC2):
# start ssh tunnel to ec2 instance that is in the same VPC as aurora
$ forever start tunnel-ssh.js
# tunnel should be running on 127.0.0.1:5432
# generate prisma code and then run server
$ npm start
# you should then see
# Server is running on http://localhost:4000
Open url in browser and checkout the docs/schema. Heres is a few example queries that we can run:
# {
# findOneUser(where: { username: "trabur" }) {
# id
# username
# }
# }
{
findManyUser(skip: 0){
id
username
}
}
# mutation {
# createOneUser(data: { username: "trabur" }) {
# id
# username
# }
# }
# mutation {
# deleteOneUser(where:{id:"cjyqlcmmf00007fvt2zxv8g9v"}) {
# id
# }
# }
Migrate your database using Lift
Every schema migration with Lift follows a 3-step-process:
- Adjust data model: Change your data model definition to match your desired database schema.
- Save migration: Run
export npm_package_config_database_url="postgresql://root:CjUH21EW1peaJYng@127.0.0.1:5432/fleetgrid?schema=public&sslmode=prefer"; prisma2 lift save --name 'init'
to create your migration files on the file system. - Run migration: after a
git push
the gitlab-ci will runprisma2 lift up
to perform the migration against your database.
note: be sure to create database named
fleetgrid
in pgAdmin before running the firstlift
migration.
Node.js behind NGINX
I used the following guides to setup our prisma node.js app behind nginx load balancer.
- https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/
- https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-2/
Publish ORM to NPM
The entire deployment process to publish a new module version has been reduced to the following commands.
# npm version 0.0.1
$ npm version <newversion>