CodingNic

Introduction to Backend Development

REST vs GraphQL (High-Level Overview)

Introduction to Backend Development 8 min read

REST vs GraphQL (High-Level Overview)

Objectives

By the end of this lesson, you should be able to:

  • Describe, at a high level, what REST and GraphQL each are
  • Explain the core difference in how a client requests data under each approach
  • Recognize why this course focuses on REST first

💡 Why this matters: REST and GraphQL are the two most common approaches to designing a web API today. This is a preview, not a deep dive, REST gets a full dedicated module later in this course, and GraphQL is covered properly in a later course in this track.

REST, at a High Level

REST (Representational State Transfer) is a style of API design built around resources, things like a user, a product, or an order, each with its own URL, accessed using standard HTTP methods. Fetching a product looks like GET /products/42, updating one looks like PUT /products/42, and so on. Each endpoint typically returns a fixed shape of data, whatever that resource’s representation is defined to include.

REST is the dominant style for web APIs today, widely understood, works naturally with HTTP’s existing methods and status codes, and is what this course’s REST API Design module covers in full depth.

GraphQL, at a High Level

GraphQL is a query language for APIs, and an alternative to REST’s many-fixed-endpoints approach. Instead of separate URLs per resource, a GraphQL API typically exposes a single endpoint, and the client sends a query describing exactly which fields it wants back, potentially spanning several related resources in one request.

Where a REST client might need three separate requests to gather a user, their orders, and each order’s products, a GraphQL client can often describe all of that in a single query, and get back exactly those fields, no more, no less.

The Core Tradeoff

REST’s fixed endpoints are simple to reason about and cache, but can lead to either over-fetching (getting back more data than needed) or under-fetching (needing multiple round-trip requests to gather related data). GraphQL solves both of those directly, letting the client ask for precisely what it needs, at the cost of more complexity on the server side to support that flexibility.

Neither is universally “better,” they’re different tools suited to different situations, and plenty of real systems expose both.

Why This Course Starts with REST

REST is simpler to learn first, maps directly onto HTTP concepts already covered in this module, and remains, by a wide margin, the most common way real-world APIs are built. This course’s REST API Design module covers it properly, resource design, versioning, pagination, filtering, and more. GraphQL gets its own dedicated treatment in a later course in this track, once REST is second nature.

Try It

  1. Explain, in your own words, the core difference between how a client asks for data under REST versus GraphQL.
  2. Give an example of a situation where fetching data with REST might require multiple separate requests.
  3. Explain what “over-fetching” means, and how GraphQL is designed to avoid it.

Recap

  • REST organizes an API around resources and URLs, using standard HTTP methods, each endpoint returning a fixed shape of data.
  • GraphQL exposes a single endpoint where the client describes exactly the data it wants, avoiding over-fetching and under-fetching.
  • Neither approach is strictly better, this course builds REST skills first, GraphQL is covered in a later course in this track.

Next lesson: installing Node.js and setting up your development environment.