GraphQL Subscriptions for Real-Time Data
Add real-time capabilities to your GraphQL API using subscriptions, so clients receive live updates over WebSockets the moment data changes.
The Three GraphQL Operations
GraphQL defines three root operation types:
- Query: read data
- Mutation: change data
- Subscription: receive a stream of live updates
Queries and mutations are request/response; subscriptions keep a connection open for ongoing events.
When to Use Subscriptions
Subscriptions shine when clients need real-time data:
- Chat messages
- Live notifications
- Collaborative editing
- Live dashboards and scores
For data that rarely changes, polling a query is simpler.
All lessons in this course
- Introduction to Serverless with Node.js
- GraphQL API Design Principles
- Building a GraphQL Server with Apollo
- GraphQL Subscriptions for Real-Time Data