serverless/serverless-graphql-relay

Name: serverless-graphql-relay

Owner: Serverless

Description: Serverless GraphQL Boilerplate using Relay ? Ready to be deployed to production within minutes ?

Created: 2017-01-16 01:30:09.0

Updated: 2018-04-30 19:52:58.0

Pushed: 2017-09-25 19:41:18.0

Homepage: null

Size: 8178

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Serverless GraphQL

This starter kit is an opinionated set of tools combined to help you get started building a Serverless application with an GraphQL endpoint and deploy them to production in minutes.

This example uses the following technologies:

Install & Run

You need to have node 6 or higher installed.

install -g serverless
install

Use mocked data (keep in mind due hard-coded data the interface might behave not as expected)

run update-schema
start
sit http://localhost:3000 in your browser

Use live data from the development environment. You need to make sure you have access to your deployed lambda functions. This works only after you deployed it to production.

run update-schema
run start:remote
sit http://localhost:3000 in your browser
Setup for Production

AWS has global unique bucket names. You need to replace <your-s3-bucket-name> in package.json as well as in the serverless.yml with your own custom name.

Since the URL of the API is unknown until you create a stack, you need to deploy once without expecting the application to work using npm run deploy. After the initial deploy you can see the API url which you need to provide to the URL entry in security.env.prod.

deploy feedback

After these steps you are good to go and with your next npm run deploy your infrastructure should up and running. Visit http://<your-s3-bucket-name>.s3-website-us-east-1.amazonaws.com in your browser.

Developing

If you make changes to the GraphQL schema stop the server, regenerate it and restart the server:

run update-schema
start
Testing

We use Jest as a test runner. To run all tests use

run test

To update component snapshots after updating a component use

run test:update
Security

At Serverless we keep our keys encrypted in the repository. We recommend you to do the same. In our case deploying to a staging and production system is done via a continuous integration system which has the secret to decrypt the necessary file with the environment variables. For demo purposes this repository has an unencrypted file for environment variables at foundation/environment/security.env.local and foundation/environment/security.env.prod.

Multiple package.json

In order to keep the total amount of code uploaded to AWS Lambda small the api directory containing the Serverless service has it's own package.json. This speeds up uploading and also should reduce the cold start time of Lambda functions. You don't have to run npm install manually at any point. It will only happen during deploy, but you need make sure every library you are consuming in your GraphQL endpoint is added as a dependency there.

package.json
api/package.json

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.