GraphQL Overview

Ask for Exactly What You Need

With REST, the product page might call /products/7, /products/7/reviews and /sellers/5. With GraphQL, the client sends one query to one endpoint (/graphql) describing the exact fields it wants.

query ProductPage {
  product(id: 7) {
    name
    price
    category { name }
    reviews(limit: 2) { rating comment }
  }
}
RESTGraphQL
EndpointsMany URLsOne /graphql
Shape of responseFixed by the serverChosen by the client
Over/under-fetchingCommonAvoided
HTTP cachingEasy (GET + URL)Harder (mostly POST)
Best forPublic APIs, simple CRUDRich UIs with many related objects