Why GraphQL?
Before you learn about the benefits of GraphQL, you might be wondering, what is GraphQL? GraphQL is a query language but not for querying databases. It's a query language for APIs, but in many cases, it may eventually interface with databases. From an API consumer's perspective, it's a query language for the client to specify which data fields it needs.
The motivation for the consumer to use GraphQL surrounds collecting payload data that's returned from APIs. In some cases, you receive more data than what is necessary and that impacts bandwidth. In other cases, you don't get enough data and need to create additional APIs to fetch additional data. Those two cases are referred to as over-fetching and under-fetching. Let's understand each of them:
- Over-fetching happens when an API returns data elements you do not need nor want. This extraneous information can be just ignored but has a cost, especially if there are lots of additional...