graphql-engine/community/boilerplates/serverless-triggers
2018-10-30 14:51:58 +05:30
..
assets add community boilerplates and examples (#430) 2018-09-13 12:00:07 +05:30
aws-lambda pep8 fixes for python files (#875) 2018-10-30 14:51:58 +05:30
azure-functions add community boilerplates and examples (#430) 2018-09-13 12:00:07 +05:30
google-cloud-functions pep8 fixes for python files (#875) 2018-10-30 14:51:58 +05:30
zeit-now update serverless triggers on zeit now (close #490) (#613) 2018-10-02 16:36:28 +05:30
zeit-serverless-docker update serverless triggers on zeit now (close #490) (#613) 2018-10-02 16:36:28 +05:30
.gitignore add community boilerplates and examples (#430) 2018-09-13 12:00:07 +05:30
README.md update serverless triggers on zeit now (close #490) (#613) 2018-10-02 16:36:28 +05:30

Event trigger boilerplates for serverless cloud functions

This repository contains boilerplate functions for various use-cases, for different serverless or cloud function platforms. These functions implement sample use-cases of the different types of asynchronous business logic operations that can be triggered by the Hasura GraphQL Engine on database insert, update or delete.

Examples in this repository support the following cloud function platforms:

  • AWS Lambda

  • Google Cloud Functions

  • Microsoft Azure Functions

  • Zeit Now

Note: If you want to add support for other platforms, please submit a PR or create an issue and tag it with help-wanted

Events Trigger and Serverless functions architecture

Architecture diagram

Setup Postgres + Hasura GraphQL engine

This boilerplate code assumes that you already have a HGE instance running.

If not you can visit the docs and setup Postgres + HGE.

Deploying the boilerplate examples

Follow the cloud function provider docs for setting these up. Provider specific README also contains CLI instructions.

Documented examples

  • A simple example to echo the trigger payload.

  • Make a GraphQL mutation on some data update/insert, from the serverless function (write related data back into the database).

  • Asynchronously send a FCM/APNS push notification.

  • ETL or data transformation: transform the trigger payload and update an algolia index.

Note: Some of the examples have a corresponding great-first-issue issue in the repository. Please checkout the checklist in the README in the cloud provider folders for such issues.

Directory Structure

Boilerplates have been organised into top-level folders for each cloud function platform. Inside each such folder, there's a folder for each language, followed by each use-case. The README for each cloud function provider has a list of available boilerplates.

The following is a representative tree of the folder structure:

.
├── aws-lambda
|   |── README.md
|   |── nodejs
|   |   |── echo
|   |   |── mutation
|   |── python
|   |   ...
|
├── azure-functions
|   |── README.md 
|   |── nodejs
|   |   |── echo
|   |   |── mutation
|   |── python
|   |   ...

Contributing and boilerplate requests

Want to contribute to this repo? Issues marked good-first-issue or help-wanted are a good place to begin. Please submit a PR for new boilerplates (other use-cases or cloud function providers/platforms like Apache OpenWhisk, etc.). You can also create issues to request new boilerplates.