Previous proposalReasonML: Strict, powerful, and forgiving.
Architecture of scalable and resilient NodeJS apps with GraphQL & event-driven serverless
Submitted by Shahidh K Muhammed (@shahidhk) on Thursday, 6 September 2018
Section: Full Talk Technical level: Intermediate Status: Confirmed & Scheduled
The true power of GraphQL lies not just in its syntax but the fact that it makes it possible to reason about applications in ways we have never thought of before. The realtime bits of the GraphQL spec is one such horizons-widening abstraction when we use it as a tool to think about architecting an asynchronous, event-driven backend.
Architecting the frontend of applications to consume a fundamentally async backend is still a challenge. GraphQL subscriptions and live-queries offer an opportunity to design a “reactive” contract between the backend and the frontend. In this model, an app makes a GraphQL mutation and then runs a GraphQL subscription to get updates as they happen. The business logic in serverless functions gets triggered automatically after the mutation and app gets success/error updates as and when they happen.
With serverless functions, we get an auto-scalable, resilient backend which is perfect for processing asynchronous actions and stateless workloads. Such tasks include sending emails/push notifications, ETL, long running business logic etc. With no servers to provision and zero ops-tasks, it is very easy for a front-end developer to write and deploy these complex logic as functions in NodeJS etc.
To draw on the Redux analogy, GraphQL mutations are actions, datastore is the “state”, asynchronous business logic are the “reducers”, and GraphQL subscriptions/live-queries become the state update glue. In this talk, I will talk about how we can use GraphQL and event-driven serverless functions to reason about the data-flow in an application.
I will start with how state of the application can be architected to be stored in the database itself and how updates to this state can be used to build reactive user interfaces which update in real-time, with GraphQL Subscriptions and live-queries. Then we will take a look at how serverless functions can be used to execute business logic and how these functions can be triggered on database events, which are updates to this state.
In short, I will go over different architecture patterns, open-source tools used, code-samples, observed benefits, and pros/cons, and how this pattern fits into the larger GraphQL and serverless revolution that we are undergoing. I will end with a small live-coding demo to show how easy it is to plan and build a reactive application.
Shahidh is an engineer at Hasura and one of the maintainers of Hasura GraphQL Engine. He, along with the team at Hasura, are exploring ways to make application development easier, using GraphQL and serverless. He is the co-author of Graphqurl, an open-source curl like CLI for making GraphQL queries. Shahidh is an experienced speaker who has spoken at many conferences in India and abroad.