Real-time updates via GraphQL subscriptions
In this recipe, we will enhance, not replace, our REST API using GraphQL subscriptions. GraphQL subscriptions are an excellent option for adding real-time notifications to our APIs without SignalR or configuring raw WebSocket. Further, we will learn how to integrate a REST API controller with GraphQL services. We will take an ordinary REST POST
endpoint and enhance it by sending a real-time update with information on a newly added resource via a GraphQL subscription. A change to our POST
endpoint will call a subscription on our GraphQL service. This can be the basis of an integrated approach – so you can start using GraphQL in your Web API while still retaining REST endpoints. Finally, we will explore observing our GraphQL endpoints with Banana Cake Pop, which is provided for us with Hot Chocolate.
Getting ready
Clone the starter project here: https://github.com/PacktPublishing/ASP.NET-9-Web-API-Cookbook/tree/main/start/chapter08...