Differences between REST&GraphQL -- my view
Original Post: https://notes.bbish.net/blog/post/yarco/REST-and-GraphQL-my-view
It was said that GraphQL is the replacement of REST. But after I read a bit on GraphQL, I actually feel it is an extension to REST.
The Point of Using GraphQL
Just like the name GraphQL, I think its aim is for fetching data – A Query Language. You have rare time on updating several different entities the same time, so REST CUD(Create, Update and Delete) is totally enough.
One of the advantages of using GraphQL’s is the agility of getting data. That is the point of using GraphQL.
The Usage of the Both
For the agility of getting data in GraphQL, it is obviously good for the situation of fast prototype and quick improvements circle at the client end. If your app is done in native language, I don’t think you will upgrade it so often. I mean:
- GraphQL is good for H5 apps & the web (they can be changed quite often)
- REST is good for native apps
Language Level
GraphQL is in some way a standalone language. But REST is just using HTTP keywords. How does that affect your usage?
For example, you need to define types in GraphQL. But if you are using some backend programming languages, why you can not reuse those classes defined in those languages? ex.: the PHP class.
Because normally those backend programming languages are too powerful that they have strong language feature like the namespace. So that classes in those languages are hard to be distinguished at the client end. It is unnecessary for the client end to know the class name in the backend.
I'm going to add GraphQL like feature in REST API in Symfony though...(But maybe no one would use it for it is not a standard)
But maybe you have other thinkings on the both.