Reasons to consider GraphQL over REST API
GraphQL gives us flexibility in receiving responses, i.e. a client consuming the GraphQL API can demand what is required. Imagine an application for listing todo lists, containing fields like title, body, status, completedAt, createdAt, and updatedAt. The REST API implementation sends all these fields. In the frontend design, the todo lists are shown initially using a title and status i.e. only 2 fields title and status are required for the listing design. Here the complete response of the API like createdAt, updatedAt, body is unused, which will increase the response size and increases the response time received at the client-side. Another approach is to design multiple API endpoints for sending different responses as required by the design. This implementation is very costly and requires high maintenance, as the implementation needs to be updated whenever the UI design changes.