BugCast
Node Node.js

REST vs GraphQL: Interview Comparison

Trade-offs, when to pick each, and how to discuss API design in interviews.

BugCast Admin··7 min read

REST

Resource-based URLs, HTTP verbs, stateless.

GET    /users/1
POST   /users
PUT    /users/1
DELETE /users/1

Pros: Simple, cacheable, wide tooling Cons: Over-fetching, under-fetching, multiple round trips

GraphQL

Single endpoint, client specifies exact data shape.

query {
  user(id: "1") {
    name
    posts { title }
  }
}

Pros: No over-fetching, strong typing, introspection Cons: Complexity, caching harder, N+1 query risk

Interview Questions

Q: When choose REST?

Public APIs, simple CRUD, heavy HTTP caching needs, team unfamiliar with GraphQL.

Q: How solve GraphQL N+1?

DataLoader batching, query complexity limits, persisted queries.

Q: What about tRPC?

End-to-end type safety for TypeScript monorepos. Great for full-stack TS teams, not for public third-party APIs.

#rest#graphql#api#interview

Related posts