GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.
Developed by Facebook in 2012 and open-sourced in 2015, GraphQL allows clients to define the structure of the data presented in a query and returned from the server, thus preventing excessively large amounts of data from being returned.
GraphQL provides a complete description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time and enables powerful developer tools.
It’s important to understand the differences between GraphQL and REST API and how they work together. Click the tabs below to explore some of the major differences between the two.
REST APIs put different information on different endpoints or paths/URLs. There is an endpoint for products and there is an endpoint for cart. They are different URLs. For this reason, if you are interested in both cart and product information at the same time, you have to run more than one HTTP request because that is how the API is structured.
With GraphQL there is only one single endpoint: /graphql
With GraphQL, you can ask more complex questions with a single API request.
“I want to know about product 1234 and I also want to know about the category tree”