REST is currently the most popular API protocol in the world. However, it’s not without issues. With over-fetching, under-fetching, and other limitations, it has become difficult to work with when there are multiple requests to an API. GraphQL was created out of this gap.
We don't want to over-fetch data because it is not efficient and leads to performance issues. On the other hand, we don't want to under-fetch because then we do not have all the data which can result in broken user experiences. Both of these are results of bad implementations of API protocols such as RESTStart using GraphQL now!
REST virtues - lightweight, scaleable and powerful enough for large systems. REST is also easy to learn and implement unlike GraphQL.
APIs are the way we read from and write to data-sources. But they suffer from the same problems as any web page: different sources have different URLs, headers, transformations. We need a better way to access this data. GraphQL lets you query multiple data-sources or APIs in one fell swoop, mixing results of different queries for use in a single application. It is typed, specifying what a field will look like before it's consumed.
GraphQL is a new way to think about APIs and a great solution to the over-fetching and under-fetching problem with REST APIs. GraphQL eliminates over-fetching because it queries only what data it needs from many different REST API sources. It eliminates under-fetching by specifying relationships between data items and by specifying exactly how to fetch something with an explicit query language. These two features complement each one another in a powerful way, making GraphQL a much better alternative for creating API services.
GraphQL makes it easy to handle the interactions through a web-based front-end client service and a mobile app. It provides developers with an additional query language for requesting data, thereby extending the capabilities of existing REST endpoints.