LearnFrenzy
Sign in Take a free test

Versioning, Webhooks and Alternatives · Lesson 25 of 30

REST vs GraphQL vs gRPC

3 min read Updated Nov 8, 2026 Saurabh Samir

REST is the default, but not the only option. GraphQL lets clients ask for exactly the data they need in one request; gRPC offers fast, strongly typed calls between services. Each solves real problems – and adds its own. Senior engineers are expected to explain the trade-offs, not just name the technologies.

In this lesson

  • The same feature in REST, GraphQL and gRPC
  • Over-fetching and under-fetching
  • A detailed comparison
  • Choosing – and combining – them

One screen, three styles

A course page needs the course title, its instructor's name and the latest three reviews.

# REST – resources; may take several requests, may return fields you don't need
GET /api/courses/rest-api                 → { id, title, description, price, instructorId, … }
GET /api/instructors/u7                   → { id, name, bio, avatarUrl, … }
GET /api/courses/rest-api/reviews?limit=3 → [ … ]
# GraphQL – one endpoint; the client describes the exact shape it wants
POST /graphql
query {
  course(id: "rest-api") {
    title
    instructor { name }
    reviews(last: 3) { rating comment }
  }
}
# gRPC – a typed contract in a .proto file; binary messages over HTTP/2
service CourseService {
  rpc GetCoursePage (GetCoursePageRequest) returns (CoursePage);
}
message GetCoursePageRequest { string course_id = 1; int32 review_count = 2; }

Over-fetching and under-fetching

  • Over-fetching: REST's /courses/rest-api returns the description and price even when the screen only needs the title.
  • Under-fetching: the screen needed three round trips. On a slow mobile network, that's noticeable.

REST has answers too – field selection (?fields=title,instructor.name), embedding (?include=instructor), or a purpose-built endpoint for a screen (the "backend for frontend" pattern). GraphQL makes this flexibility the core of the design.

Comparison

RESTGraphQLgRPC
TransportHTTP/1.1+, any methodHTTP, usually one POST endpointHTTP/2 (HTTP/3 emerging)
Data formatJSON (any media type)JSONProtocol Buffers (binary)
Contractoptional (OpenAPI)required schema, introspectablerequired .proto, code generated
Fetchingfixed shapes per endpointclient chooses fieldsfixed messages per method
HTTP cachingexcellent (GET, ETag, CDNs)difficult (POST, varied queries)none built in
StreamingSSE, chunked responsessubscriptionsfirst-class (client, server, bidirectional)
Browser supportnativenativeneeds gRPC-Web or a proxy
Debuggingcurl and a browserGraphiQL, good toolingspecial tools (grpcurl)
Main riskschatty clients, inconsistent designexpensive queries (need depth/cost limits), N+1 database callsharder to expose publicly

Choosing

  • REST – public APIs, partner integrations, CRUD-style services, anything that benefits from HTTP caching and universal tooling. The safe default.
  • GraphQL – a rich frontend (or several) aggregating data from many sources, where screens need different shapes and round trips matter.
  • gRPC – internal service-to-service calls with high volume and low latency, polyglot microservices, streaming.
  • They combine well: gRPC between internal services, a GraphQL or REST gateway for frontends, REST for public partners.

Practice

Try it yourself

  1. Pick a style for: (a) a public payments API for merchants, (b) twenty internal microservices exchanging thousands of calls per second, (c) a mobile app showing dashboards from five backend systems.

    Show answer

    (a) REST – universal, cacheable, easy for merchants in any language, with OpenAPI docs and webhooks. (b) gRPC – compact binary messages, HTTP/2 multiplexing, generated typed clients. (c) GraphQL (or a REST backend-for-frontend) – one request per screen with exactly the fields needed.

Quick check

What is over-fetching?

Receiving fields the client doesn't need.

Why is HTTP caching harder with GraphQL?

Queries usually go via POST to one URL, with varied shapes.

What format does gRPC use?

Protocol Buffers, a compact binary format defined in .proto files.

Summary

  • REST: resources and HTTP semantics – the universal default with great caching.
  • GraphQL: client-shaped queries – fewer round trips, needs query cost controls.
  • gRPC: typed, fast binary RPC – ideal between internal services.

Finished this lesson?

Mark it complete to track your progress, then carry on with the next lesson.

Next lesson

Popular