Architecture of scalable and resilient NodeJS apps with GraphQL & event-driven serverless
Channel: Hasgeek TV
Date: 30/10/2018

Shahidh Muhammed, Hasura

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.

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.