Skip to main content


Showing posts from May, 2021

GraphQL Subscriptions In Angular Using Apollo Angular Library

In this article, we are going to understand GraphQL Subscriptions in an angular application using the Apollo Angular Library. Graphql Subscription: GraphQL subscriptions are a way to push data from the server to the clients that listen to real-time messages or payload or data from the server. Subscriptions are similar to queries in that they specify a set of fields to be delivered to the client, but instead of immediately returning a single response, a result is sent every time a particular event happens on the server. So for this demo, I have created a GraphQL endpoint in .Net5. So I'm going to use that as my server. Publisher: Subscriber: So above 2 images like 'Publisher' and 'Subscriber' are tested using the browser. Now we will implement those publisher and subscriber functionalities into the angular application. Create An Angular Application: Let's begin our demo by creating an angular sample application. Command To Install Angular CLI:(If not insta

A Demo On HotChocolate GraphQL Subscriptions(Pub/Sub) Using Application InMemory Storage

This article will implement a small demo on subscriptions in Hot Chocolate Graphql using the application In-Memory storage. Since our target storage is application In-Memory, so this approach only apt for a single server hosted application. For applications with multiple servers then we have to use Redis Store. GraphQL Subscription Flow: In general, events raising or publishing will be triggered from the GraphQL mutation resolvers. Inside mutation resolvers raise the event to store the data into application in-memory storage. In GraphQL 'Subscriptions' is one of the root definitions like 'Query', Mutation'. So the subscription resolvers will always receive the data from in-memory storage. So the subscription resolvers can also be called subscribers whose job always watches the data send by the raised events. So the event raised from the mutation resolver will be received by all subscribers. Create A .Net5 Web API App: Now let's begin our journey by creat