We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to publish this job!

Login or register
to save this job!

Login or register
to save interesting jobs!

Login or register
to get access to all your job applications!

Login or register to start contributing with an article!

Login or register
to see more jobs from this company!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Login or register
to save articles!

Login to see the application

Engineers who find a new job through JavaScript Works average a 15% increase in salary 🚀

You will be redirected back to this page right after signin

Blog hero image

REST API vs GraphQL

Chidinma Iwu 21 April, 2022 | 3 min read

WHAT'S AN API?

API, an acronym for Application Programming Interface, is a type of software that connects two applications and allows them to interact with each other. They are more like a group of coordinated functions that allow applications (Twitter, Twitch, Apple music, etc) to retrieve data from external software components or operating systems, and interact with them. When you use apps like Spotify or Apple Music to stream a song, you're using an API. In simpler terms, when you try to use an application to perform a function, the application connects to the internet and delivers data to a system. The system collects the sent data, translates it, and performs the needed instructions. It then sends the translated data back to your phone in a readable way. Think of it not exactly as a bridge, but as someone who helps you cross a bridge.

The creation of REST API was in 2000 when a group of experts led by Roy Fielding decided to change the complex nature of APIs at the time. The aim was to design two servers that could communicate and exchange data to and from anywhere in the world. Although there were numerous rules, APIs became less complex and integration was easier to facilitate. Ever since, eBay, Amazon, Flickr and other major e-commerce businesses have launched APIs to increase the visibility of their products and their opportunities. REST is an acronym for Recreational State Transfers which is a software style that was created to oversee the design and development of the World Wide Web's architecture.

When a request is made via REST API (or RESTful API), it transfers an interpreted representation of the resource to the requester. This information is delivered in any of the many compositions through HTTP, which are Python, HTML, XLT, PHP or JSON (Javascript Object Notation). JSON is the most popular file format to use because both humans and machines can read it.

WHAT IS GraphQL?

In 2012, Facebook created GraphQL and started using it for mobile operations. It was created as an alternative to REST API as the company encountered issues that required extra work from the engineers to keep services running. REST API was slow on the network, had fragile client/server interactions, and used tedious processes. Mark couldn't work with this as it was a limitation for his fast developing company and the idea to initiate a new approach was introduced. This is how GraphQL began. In 2015, the GraphQL specification was open-sourced to the public. Since then, the software development community uses it as one of the best technology stacks for developing and building web services. It is now managed by the GraphQL Foundation.

This new method introduced by Facebook's best Engineers —GraphQL —was designed to be a query language used to fetch only the data that a client wants from the database. GraphQL allows for a complete and comprehensive definition of the data in your API, it gives clients the power to ask for what they specifically need, makes it easier to evolve APIs over time, and enables powerful developer tools. It was built to make APIs fast and flexible.

REST and GraphQL.

It is important to note that GraphQL wasn't created to be a replacement to REST, it was created as an alternative to let developers construct requests that pull data from multiple data sources in a single API call. Still, there are some disparities and factors which make developers choose one more than the other.

While REST strengths range from being easy to understand and learn, having the ability to organize complex applications, simplifying client actions to work on various applications, and using standard HTTP procedures to collect data and requests, there are a number of its disadvantages that may have prodded companies like Facebook and Coursera to prefer it over REST.

The top two extremes are usability and performance.

PERFORMANCE.

In REST, when an API endpoint is called to request data that the client app needs, the server sends back the response based on the requested query. When someone uses REST API, they would first have an endpoint, say a blog site, this endpoint would acquire the author’s information. Now another REST endpoint is needed to retrieve the posts and finally, you would need another endpoint to collect the blog topics. If you follow keenly, you'd note that there's a lot of time-wasting with the numerous roundtrips. This is not so with GraphQL though, in GraphQL, it is simpler to deal with numerous databases and every represented data can be fetched with a single API call. Also, apps that use GraphQL can be fast even on a slow mobile network connection.

USABILITY.

GraphQL's high predictability is arguably its strongest forte. It lets users send a request to their API and get exactly what they require and there aren't any irrelevant inclusions. Its queries return foreseeable results and this scales its usability. On the contrary, REST’s behaviour is often determined by the URI and HTTP methods implored. This makes it unclear for an API consumer to know what to expect when calling a new endpoint. There are no standardized and clear guidelines for REST when it comes to versioning. This implies that every provider is free to implement their approach.

These strong differences between REST and GraphQL are currently making the latter top the charts with developer reviews as even though GraphQL is still in its steam gaining process and not as old as REST, it is proving to be more reliable, fast, and accurate for web development.

Author's avatar
Chidinma Iwu
more a shitposter than a journalist. black woman. bylines: @dailydot @BlackBalladUK @thebizofbiz, @Brittlepaper, @writersofcolour & more.

Related Issues

open-editions / corpus-joyce-ulysses-tei
open-editions / corpus-joyce-ulysses-tei
  • Started
  • 0
  • 16
  • Intermediate
  • HTML
open-editions / corpus-joyce-ulysses-tei
open-editions / corpus-joyce-ulysses-tei
  • Started
  • 0
  • 5
  • Intermediate
  • HTML
open-editions / corpus-joyce-ulysses-tei
open-editions / corpus-joyce-ulysses-tei
  • Started
  • 0
  • 5
  • Intermediate
  • HTML
open-editions / corpus-joyce-ulysses-tei
open-editions / corpus-joyce-ulysses-tei
  • Started
  • 0
  • 7
  • Intermediate
  • HTML

Get hired!

Sign up now and apply for roles at companies that interest you.

Engineers who find a new job through JavaScript Works average a 15% increase in salary.

Start with GitHubStart with Stack OverflowStart with Email