Serverless Pattern: https://cloudacademy.com/blog/how-to-write-graphql-apps-using-aws-lambda/
Auth Pattern: https://docs.scaphold.io/tutorials/authentication-in-graphql/
Sequalize Steps:
- createdb graphql-lambda (creates database)
- sequelize model:create --name Book --attributes "title:string" (create model)
- sequelize db:migrate (add book table to db)
- sequelize migration:create --name "add-content" (create empty named migration file, must code up/down logic)
- sequelize db:migrate (apply migration created in last step)
- ---- (no command, must add any changes to the model manually after a migration)
Initialize Test DB:
- createdb graphql-lambda-test
- NODE_ENV=testing sequelize db:migrate
Important PostgreSQL Commands:
- psql postgres -U root (connect to database as user)
- \l (list databases)
- \c graphql-lambda (connect to graphql-lambda database)
- \dt (list tables in connected database)
- SELECT * FROM "Books"; (simple query, sequalize will capitalize table name by default and without quotes postgreSQL will try books instead)
Current Deploy Process:
- docker build . -t aws-linux (build from dockerfile, installs aws specific dependencies)
- docker run -i -t aws-linux (launch container, starting server to leave container open)
- ---- (open new terminal)
- docker ps (print containers, copy container id of aws-linux container)
- rm -rf node_modules/ (remove local node_modules directory)
- docker cp ${container_id}:/app/node_modules ./node_modules (copy aws linux node_modules from container to local directory)