A practical use case – exposing federated data models using GraphQL
In this section, we will learn how to develop DaaS using GraphQL in Java. To implement the solution, we will publish the same set of APIs that we published earlier using REST, but this time, we will implement the solution using GraphQL.
Before we start implementing GraphQL, it is important to design the GraphQL schema for our use case. In our use case, we need to read credit card applications from MongoDB using either the application ID or consumer ID. This was why we needed two separate endpoints in the REST-based solution (please refer to Chapter 9, Exposing MongoDB Data as a Service, for the REST-based DaaS solution).
Let’s analyze the requirements from a different perspective – that is, while considering the GraphQL-based solution. The biggest difference that GraphQL makes is that it reduces the number of endpoints, as well as the number of calls. So, for our use case, we will have a...