REST vs GraphQL RapidAPI Comic cover.
GraphQL is a query language that can request specific data from a server, represent 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 a single fish being caught on a hook, the same way GraphQL can return specific data. GraphQL does this thanks to schema definition language, and only requiring a single endpoint.
Advantages of REST. It is easy to use, flexible and scalable, and client and server independent. Advantages of GraphQL. It is fast, requires less bandwidth, and can be tailored to your data needs.
You should choose between GraphQL and REST based on your applications needs. Diagram 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.