GraphQL: Designing Flexible and Efficient APIs
This chapter is about building APIs with GraphQL. GraphQL offers a more flexible approach to creating APIs when compared to REST. GraphQL gives clients the ability to query only the data they need—no additional or unnecessary data is returned.
We start off by exploring real-time updates via GraphQL subscriptions. Real-time updates are something entirely absent from REST. REST APIs require us to use infrastructure such as SignalR or raw WebSocket implementations for real-time features. In contrast, GraphQL subscriptions provide this capability as a native feature of the protocol. While SignalR excels at real-time communication with features such as groups and connection management, GraphQL subscriptions offer a more integrated approach when you need real-time updates within your data query layer. The main benefit is that it is easy to send real-time updates using the same GraphQL schema and type system you use for your queries...