Nerd For Tech
Published in

Nerd For Tech

Is it time for REST APIs to rest and GraphQL to rise?

Another interesting advance in technology in the past few years is the move to GraphQL. After years of preaching for RESTful APIs, now companies are moving to GraphQL. Currently, I am working on a project to migrate from an explosion of RESTful APIs to GraphQL. It was interesting to see the adoption of REST going up and suddenly declining, as the case with many technologies. Just a few years, ago, I read an article that reads “REST in peace, SOAP” (https://royal.pingdom.com/rest-in-peace-soap/ ). The move, at this time, was from SOAP to REST. After few years of using REST, here we go again. REST in peace, REST :) (https://nordicapis.com/is-graphql-the-end-of-rest-style-apis/ ). Is not this the case with technological advancement these days? Now, the question is: why people may choose GraphQL over RESTful APIs?

1. One endpoint vs multiple endpoints:

The main problem I am experiencing today is the explosion of end points that are hard to be discovered and not well documented. You may have to create an endpoint per resource. For example, if you have a database of Posts, you may have Posts collection, Comments collection, and Authors collection. To get a post you call GET mydomain.com/posts. In this case, you get all posts with Author Ids. To get user information, you have to do another call per post to get user info GET mydomain.com/Authors/:id. Then to get the comments on each post, you need to run multiple other requests. Then to get users wrote each comment …. You got the idea.

In GraphQL you just run a query with nested queries of what you want in one shot. Is not this cool :)

2. Network Requests:

It is obvious from the example above that you do a lot more requests in REST than GraphQL. In this case, GraphQL reduces network requests, which improves performance and speed.

3. Over / Under fetching:

In RESTful APIs, you get the entire output in spite of what you need (over fetching) or you might get less than what you need and you will have to do multiple rounds like the first example (under fetching).

4. Versioning:

One of the major problems with RESTful APIs is versioning and backward compatibility. GraphQL is version less. You can introduce/deprecate fields easily.

5. Documentations:

This is one of the great benefits of GraphQL. As you know, developers hate documentations and updating them. This comes for free with GraphQL.

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

Apache Pulsar 2.6.0

Video: What is the Bring Up Process for Industrial Autonomous Vehicles?

SAP DevOps — The Cost of Managing a Change in SAP Landscape

Top 4 Tasks to Automate with Web Automation

æpps Update: Beginning of May

Active Record Validations

Hire a Startup Development Team

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
Rany ElHousieny

Rany ElHousieny

https://www.linkedin.com/in/ranyelhousieny Commercial software development manager offering 25+ years of technical experience. Certified Solutions Architect

More from Medium

Hadoop Developer- Roles and Responsibilities

Dynamic multi period capacity planning problem.

Keeping your schema.rb file clean and consistent between environments

How to Measure Latency from Radar Interfacing to Display