GraphQL vs Rest API

Introduction to GraphQL

GraphQL is a data query language architectured and developed by Facebook. It was developed for as an alternative to REST API. It gives a total and reasonable depiction of the information in your API, enables customers to request precisely what they need and nothing more makes it less demanding to advance APIs after some time and empowers ground-breaking developer tools.

Introduction to REST API

For the past decade or so we have been using REST API. It is the most popular API. Most of the businesses have adopted the trend of REST API. This can be used over nearly any HTTP methods. As it works on HTTP as well as HTTP2 protocol, this enables developers to reduce the dependency over additional software.

Similarities between Rest and GraphQL

We come across a new problem with every evolving technology and hence we come up with a new technology that intends to solve those problems. But there lie some similarities between them and this is also true with these two APIs. So what could these two share for all intents and purpose? Indeed, one clear thing they share for all intents and purpose is that they are the two details for building and expending APIs. Additionally, REST and GraphQL can both be worked over HTTP, however, GraphQL is convention skeptic. GraphQL Endpoint is mostly called using an HTTP post Method.

Differences between Rest and GraphQL

So now we can come to the differences and see exactly what problems these two API’s were intended to resolve.

Data Fetching

GraphQL has a query based data fetching mechanism. In case of REST API, several requests are made to single or multiple endpoints for data retrieval purpose.

Network Requests

It might take REST to make 10 requests to get a particular data but using GrapgQL, a significant advantage is that can now be done in one request itself.


In GraphQL we can request only for the data we want and ignore fetching of unwanted data.

But the same isn’t true for REST, as it fetches everything, from which unwanted data need to be discarded by the endpoint consumer.

Error Handling

Error handling in REST is pretty clear, we essentially check the HTTP headers to get the status of a response. Depending on the HTTP status code (404, 503, 500, etc.) we get, we can without much of a stretch tell what the Error is and how to approach settling it. GraphQL then again, when worked over HTTP, we will always get a 200 OK reaction status.


As REST is implemented using Http which already has caching baked in, it avoids refetching of data. However, GraphQL has no caching functionality baked in for caching.

Tools Used for Graphql

• Graphiql

• Apollo Optics

• Graphcool

• GraphCMS

Tools for RestAPI

• Postman

• Insomnia

• Rest Client


Based on my experience, I feel GraphQL reduced my coding time by considerably reducing the code that I had to write as compared to what I had to write for the REST API. There is no perfect fit for all situations and conditions and so first you will need to check your situation and need, then based on that, you will have to make your decision.


Snivio Braganza

Post Comments

* marked fields are mandatory.