serverless-boilerplate-graphql v0.0.3

Serverless GraphQL Boilerplate
This boilerplate application features a serverless architecture that leverages new technologies (Lambda, GraphQL) to reach a very low total cost of ownership (i.e., least amount of code, administration, cost).
Setup
If you haven't yet installed serverless on your machin, run:
npm install -g serverlessthen install the GraphQL Boilerplate in the CWD by running:
sls project install serverless-boilerplate-graphql
cd serverless-boilerplate-graphqlBack
Add the authTokenSecret variable to _meta/variables/s-variables-STAGE-REGION.json and give it a strong value. This is the secret used to generate JSON web tokens. Then:
cd back/api
npm install
sls function deploy --all
sls endpoint deploy --allClient
Set API_URL in client/src/app/js/actions/index.js. Then:
cd ../../client/src
npm install
npm startThis will runs the client locally. You can then deploy the client to an S3 bucket with:
npm run build
sls client deployDeploying to S3 bucket
Make sure you're still in the client/src folder mentioned above, then run:
npm run build
sls client deployTesting With A Local DynamoDB Instance
- Install Docker
- Run
docker-compose upto install and run DynamoDB. - Add the
localDynamoDbEndpointvariable with the valuehttp://<DOCKER-MACHINE-IP>:8000to_meta/variables/s-variables-common.json. Example value:http://192.168.99.100:8000. - Run
sls setup db -s <stage> -r <region>to create tables in the local DynamoDB instance. - Run
sls offline startto start the offline server.
Testing With GraphiQL
If you're running OSX, you can use the GraphiQL Electron App to test the GraphQL backend without a client:
- Install brew cask for easy installation:
brew tap caskroom/cask - Install GraphiQL App:
brew cask install graphiql - Open GraphiQL application. Just search for
GraphiQLusing OSX Spotlight Search! - Add your
dataendpoint to the "GraphQL Endpoint" text field, and make sure the "Method" is set toPOST. - Try this mutation to create the first user:
mutation createUserTest {
createUser (username: "serverless", name: "Serverless Inc.", email: "hello@serverless.com", password: "secret") {
id
username
name
email
}
}- Now list all users using the following query:
query getUsersTest {
users {
id
username
name
email
}
}- You should get the user you just created:
{
"data": {
"users": [
{
"id": "aca42ee0-f509-11e5-bc11-0d8b1f79b4b9",
"username": "serverless",
"name": "Serverless Inc.",
"email": "hello@serverless.com"
}
]
}
}Team Workflow with Meta Sync Plugin
This boilerplate includes the Meta Sync Plugin. To start using it you need to add the following serverless variables to _meta/variables/s-variables-common.json:
"meta_bucket" : "SOME_BUCKET_NAME",
"meta_bucket_region" : "us-east-1" // or any other region