Posted on July 31, 2021
Original post is here.

As a Full-stack developer, I believe no tool is perfectly better than others. Everything has flaws. Take REST API as an example. Though REST API is popularly used API standards, it has one known problem.
Before jumping into the problem, I am going to discuss some introductory terms.
API is the short form of Application Program Interface, which means the way of interaction between programs. Developers develop API on server side so that other applications can requests data through this API.
REST is the short form of REpresentational State Transfer. It is a set of rules to create API. Look at below image for better understanding,

Example of REST API. [Image source]
It seems everything perfect with REST till now. REST API is good as it defines standards to create API. But there is one major issue with REST API.
Let’s talk about the issue now. For example, you developed an API for your awesome blog site. An API (fetching user profile information) is like below,

Suppose, for blog site purposes, you need user information in two places on the website. One place is the User Profile page where the user updates his profile information. Another place is the blog post comment page, where the user image and username are used in a comment card.
![]()
comment card
You can use the /user-profile API in both places. But in the comment card, you get some unnecessary data like firstname and lastname. To avoid this problem, you can build another API only for comment card like below,

The API for a comment card
If you have another case where you need only firstname, what will you do? Building another API?
To solve the issue, GraphQl Comes into play.

#1 Same endpoint- I need id, username, and name

#2 Same endpoint- I need id, email
If you look at the above images, you see the endpoint is the same. What I need to do is asking for data that I need. That’s how GraphQl solves the problem of REST API.
The purpose of this blog post is just to discuss how GraphQl is better than REST API. The purpose is fulfilled 🔥. Recommended site of GraphQl — https://graphql.org/.