Why GraphQL?

GraphQL

Origin

REST and its shortcomings

  • to access all blogs: /blogs
  • to a blog identified by id 27: /blogs/27
  • GET /blogs : a collection of blogs
  • POST /blog : create a blog
  • PUT /blogs/27 : update blog identified by id 27
  • DELETE /blogs/27 : delete blog identified by id 27
query FetchUserBlogsAndCommentsQuery {
user(id: "123"){
id
username
email
blogs{
title
description
tags
comments{
author{
username
}
text
}
}
}
}
{
"data":{
"user":{
"id": 123,
"username": "John Doe",
"email": "john@doe.com",
"blogs":[
{
"title": "Why GraphQL??",
"description": "GraphQL was developed to cope with the need for more flexibility!",
"tags": ["GraphQL", "REST", "API"],
"comments":[
{
"author": {
"username": "Jane Doe"
}
"text": "This blog clearly explains why GraphQL was needed, Helped a lot!!"
}
]
}
]
}
}
}

Smaller precise payloads

Over-fetching leads to downloading more data

Under-fetching for n+1 problem

Benefits of a Schema and Strictly Type System

Documentation

No more versioned APIs

Better performance and rapid frontend iteration

REST is GOOD GraphQL is BETTER

Get in touch

--

--

--

Software Engineer, Front-end and Back-end developer, with interest in building scalable, highly efficient, resilient and user-friendly systems.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

All about AWS SNS

Optimising memory usage in Python code

The Digitalization Exploration of Damaiwang in the Entertainment Industry

However, Harbaugh’s window of opportunity to build Michigan Football

xHashtag Whitelist Application Process on SolRazr

Starting with Ansible

Kubernetes Tip: How Kube-Proxy Realizes SVCs ?

Test Plan : Is It Mandatory to Create Test Plan?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jay Gurav

Jay Gurav

Software Engineer, Front-end and Back-end developer, with interest in building scalable, highly efficient, resilient and user-friendly systems.

More from Medium

Custom software development — the key to business scalability

Organizations should consider purchasing npm libraries

Nested Pagination with Apollo Client 3 Type Policies

Plex’s 2021 Journey with Next.js and Vercel