The Core Difference Between REST API and GraphQL


GraphQL is often touted as an alternative to REST APIs. In this section, we will look at the gap between GraphQL and REST with an example and look at how they both can synchronize and complement each other.

GraphQL is typically introduced in comparison to REST, but at this point, these comparisons are very common and cover many of the basics differences between GraphQL and REST. Instead of reiterating these points, this article will focus on a few more variation differences between GraphQL and REST.


What is REST API?

With REST, we may have a /authors/:id endpoints to fetch an author and another /authors/:id/posts endpoints to fetch the post of that particular author. At last, we could have /authors/:id/posts/:id/comments endpoints that fetch the comments on the post.


In other words, I should be able to make changes to my mobile application without impacting either the data structure or the database design on the server. At the same time, I should be able to update the database or make changes to my server application without affecting the mobile client.


Instead, each call has the necessary data in itself, such as the API key, access token, user ID, etc. This also helps increase the API’s reliability by having all of the data necessary to make the call, instead of relying on a series of calls with server state to create an object, which may result in partial fails.

HTTP Methods

HTTP Methods
HTTP Methods
HTTP Methods

HTTP Response Status Code

HTTP Response Status Code
HTTP Response Status Code
HTTP Response Status Code


  • High performance (especially over HTTP2)
  • Proven for decades
  • Works with any representation
  • Affordance-centric


  • Poor or no tooling for clients
  • No framework or tooling guidance
  • Requires discipline on all sides
  • Challenging to keep consistency and any governance


What is GraphQL?

GraphQL has three main characteristics:

  • It lets the client specify exactly what data it needs.
  • It makes it easier to aggregate data from multiple sources.
  • It uses a type system to describe data.


  • Easy to produce and consume
  • Lots of hand-holding
  • Contract-driven by nature
  • Built-in introspection


  • Query optimization
  • You are on your own with scaling and performance
  • JSON representation only

About GraphQL mutations

If queries are the GraphQL equivalent to GET calls in REST, then mutations represent the state-changing methods in REST (like DELETE, PUT, PATCH, etc).

A query to fetch all the pets from the app might look like this:
query GetAllPets {
pets { name petType }

And then a mutation that adds a new pet might look a little something like this:
mutation AddNewPet ($name: String!, $petType: PetType) {
addPet(name: $name, petType: $petType) {
id name petType }

query { hero { name height mass } }

{ "hero": { "name": "Luke Skywalker", "height": 1.72, "mass": 77 } }


But to complete a schema, you usually need to add GraphQL operations. The GraphQL operations provide the information needed to generate and validate operations on the data graph.

  • Object type
  • Scalar type
  • Query type
  • Mutation type

type BlogPost {

type Author {


The data fields for the Blogpost entities are title and content, and both are type String. If a field is mandatory, specify this with an exclamation point.
type Blogpost {
title: String!
content: String!

type Author {
name: String!


Originally published at Reveation Labs Blog Page

Custom Software Development Solutions For Startups and Enterprise Businesses.