REST and GraphQL are both API design styles. Let's take a look at how REST and GraphQL function, their differences, and which you should choose to use.
GraphQL is a query language that can request specific data from a server, represented as a fishing rod. REST is an architectural style that is popular in REST APIs used across the web. Here it is represented as a fishing net.
REST APIs return data from a server in a way that returns the whole data set. This is represented as a fishing net catching a school of fish all together.
GraphQL is represented as a single fish being caught on a hook, the same way GraphQL can return specific data. GraphQL does this thanks to schema definition language (SDL), and only requiring a single endpoint.
The advantages of REST are that its easy to use, flexible and scalable, and client and server independent. On the other hand, GraphQL is fast, requires less bandwidth, and can be tailored to your data needs.
You should choose between GraphQL and REST based on your application's needs. The comic shows the fishing net being used to sell fish at a market, and the single fish from the hook being fed to a cat, representing how data requirements differ.
In general, GraphQL is more suitable for mobile applications and microservices, or where bandwidth might be a concern. REST APIs are fast, familiar, and provide everything a developer needs from an API service.