DEV Community

REST vs GraphQL APIs, the Good, the Bad, the Ugly

Xing Wang on February 27, 2018

note, this doc is written by my co-worker Derric, but we blog at the same place. Since being introduced by Facebook, GraphQL has taken the API ...
Collapse
 
atakan profile image
Atakan

Very well explained, thanks for sharing!

Collapse
 
gyandeeps profile image
Gyandeep Singh

very well put together post. Thanks for sharing.

Collapse
 
tiffengineer profile image
tiff

There was so much explained to me in this post that I did not get elsewhere, after months of trying. Thank you so much @xngwng .

Collapse
 
maxgoldst profile image
Max Goldstein

Regarding your section on "shared nothing", you are correct that as long as any API endpoint can be serviced by a single backend microservice, all you need is a gateway to route the incoming request to the correct service. However, as soon as you want an endpoint that pulls data from multiple microservices, it appears to me that REST isn't particularly helpful. You essentially have to handle the request in the gateway, which makes internal requests (REST, GraphQL, kafka, whatever) to the microservices. The gateway then has to compose the outgoing JSON which requires knowing about two internal APIs and one external one. With GraphQL, the notion of resolvers makes this somewhat easier.

Collapse
 
kjellski profile image
Kjell Otto

Thanks for the nice and clean writeup!

Collapse
 
taverasmisael profile image
Misael Taveras

A perfect clean wrap up of both technology, very impartial and meaningful. I can say I have a more clear idea of what to use when

Collapse
 
jitheshkt profile image
Jithesh. KT

I think Instagram is using GraphQL.? Can anyone analys the response of '?__a=1' and confirm.?

For example : instagram.com/jitheshkt/?__a=1

Collapse
 
zerquix18 profile image
I'm Luis! \^-^/

It only says "graphql" but you can't manipulate anything that it returns. Also I think it's not documented, so they change things with no notice. Recently my code broke because they changed something :(

Collapse
 
jitheshkt profile image
Jithesh. KT

Yes they do that often. Instagram doesn't entertain out of the API calls I believe. Even this particular response structure changed three or four days ago. Two of my production sites broken.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Are GET requests that so good? What turn me off about GET is character limits and it shouldn't have a body... (that is not suitable for relatively large JSON.)

Collapse
 
xngwng profile image
Xing Wang

When to use GET vs POST is NOT really related to the topic of GraphQL vs. REST.

Actually, check out this complete guide: moesif.com/blog/api-guide/api-desi...
There is a few articles regarding things to consider on when to use GET vs POST for designing APIs.