DEV Community

GraphQL : The new REST?

Nathan on March 31, 2022

GraphQL was created in 2012 by Facebook as a way to make it easier for developers to fetch the data they need from the Facebook API. GraphQL provid...
Collapse
 
curiousdev profile image
CuriousDev

Just my opinion, but GraphQL and REST are different things. The one is not supposed to replace the other.
Also I want to add that REST can be easier to use, but you can also correct me. Having different URLs for different kinds of records is not necessarily worse.

Collapse
 
sanchezdav profile image
David Sanchez • Edited

Great post, but I don't think Graphql is more efficient than REST, both have cons and pros, and they are different tools, the purpose of Graphql wasn't replace REST, I wrote this article describing both honeybadger.io/blog/graphql-apis-f... so happy to share ideas 🙌

Collapse
 
gklijs profile image
Gerard Klijs

Nice blog, it depends on the use case, but GraphQL defenitely shines for frontend API's. Recently updated a bank demo. For Spring Boot there are also good options, with Netflix DGS and Spring GraphQL. Most interesting things with GraphQL happen in js through. The work The Guild put in is amazing.

Collapse
 
thechrisjasper profile image
Chris Jasper

Nice write up. I'm not so sure I'm sold on Graph yet. For me the trade offs aren't ideal. I've only dabbled but from what I remember, Graph put a lot of pressure on the persistence layer and dictated some things there that were annoying. I guess anything that weaves it's way through to the backend gives me some concern. I like to keep things as decoupled as possible.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

It's been a few years and I have yet to see any real-world problem that GraphQL solves that hadn't been solved by SQL several decades ago.

Collapse
 
gklijs profile image
Gerard Klijs

SQL is for databases, GraphQL (mainly) for frontends. It's apples and oranges.

Collapse
 
aprmintacpineda profile image
April Mintac Pineda

It's because this post failed to highlight the actual strength and use case of GraphQL and tried to present GraphQL as a replacement for REST which is not true. But once you actually learn it and use it, you'll appreciate what it allows you to do.

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

That very much aligns with my point though; GraphQL is not a replacement for REST because they're different things. GraphQL is a query language, just like SQL is. So it's those two that should be compared, while REST has little to do with either of them.

Thread Thread
 
gklijs profile image
Gerard Klijs

I would argue they are 3 different, which each there own good use cases.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

You query your front-ends for data?

Thread Thread
 
gklijs profile image
Gerard Klijs

No.. But traffic between a backend service and frontend, or backend service and a database, is something different right?

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

No, not really. In the end, you're querying data. It's the same thing. This should be made abundantly clear by simply comparing GraphQL and SQl. The former is little more than a simplified version of the latter forcefully pressed into a more JSON-like syntax.

Thread Thread
 
gklijs profile image
Gerard Klijs

Not really, security, error handling, depreciation, are all totally different.

Collapse
 
charlesmillers profile image
CharlesMillers

this is a good way to express valuable information to a rational people they can understand it easily . black magic removal in Kerala

Collapse
 
nathan20 profile image
Nathan

Thank you ! But please remove your link
thank

Collapse
 
charlesmillers profile image
CharlesMillers

what is bad in this link .

Collapse
 
mcwolfmm profile image
mcwolfmm

REST is an architecture. RESTful is a rest architecture over http. GraphQL is only a data format. So, compare apples to pears.

Collapse
 
nathan20 profile image
Nathan

I agree they are different, and it can be difficult to compare them. But Both apple and pear are fruits that were made to be eaten..
The end goal looks alike with different data structure and ways to bring data . That is my opinion.

Collapse
 
mcwolfmm profile image
mcwolfmm

you're already talking about data, so it's time to start comparing the same things.
GraphQL uses the REST architecture (in particular, restful if it uses http as a portable protocol).
The difference is in the form of the data used. in other words, you can compare GraphQL with JSON or SOAP.

Collapse
 
aprmintacpineda profile image
April Mintac Pineda
  • Graphql is not meant to replace rest. If it is, then why hasn't it? It's been 10 years and even Facebook itself is sending an http request to an endpoint to mark a chat message as seen when I open the corresponding chat box. -- fun fact: find this endpoint, block it, and the messages you receive will never be marked as seen.

  • With GraphQL, you will need to maintain multiple resolvers, that's literally how GraphQL works behind the scene, resolvers. And yeah you can use other GraphQL engines out there but they are not without limitations, they are actually very limited in functionality, unlike building your own, hence, they allowed custom mutation and queries.

This post is very misleading and should either be corrected by the author or taken down, otherwise inexperienced devs who will read this will be mislead.

Collapse
 
nathan20 profile image
Nathan

about facebook's bug you should report it ...

Collapse
 
gethackteam profile image
Roy Derks

REST and GraphQL are two different things. However, they can be mutually beneficial. You can use a REST API to create a GraphQL API in example stepzen.com/getting-started?detail...