From the course: Learning GraphQL
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Working with subscriptions - GraphQL Tutorial
From the course: Learning GraphQL
Working with subscriptions
- [Instructor] So far, we know that queries get data and mutations change data. But there is even a third type of GraphQL operation called a subscription. A GraphQL subscription works over web sockets and it sets up a listener. So let me show you how this works. I could create a subscription for liftStatusChange, grab the name and the status, and now I'm going to go ahead and click Play. This is going to listen for any data changes in real time. And then if a status is changed over here in another panel, we're going to see all of these come back in the browser immediately. So again, unlike a query, which we just send the query, we get a response, a subscription, we set up a listener. So we're listening for any of those changes. As soon as they come in, they will be present here in our user interface. So this is pretty cool. A subscription sets up kind of that real-time feel in your application. These were first implemented at Facebook and they were used for live likes. When you see…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.