Course contentsShow
← Software Engineering
Lesson 823 of 1,93325. RPC and GraphQL API DesignFree lesson

REST vs RPC vs GraphQL: Core Trade-offs

Compare the fundamental trade-offs between REST, RPC, and GraphQL in terms of complexity, flexibility, and use cases.

REST vs RPC vs GraphQL: Core Trade-offs

What you'll learn: How to weigh the key differences between REST, RPC, and GraphQL to choose the right API style for your project.

The Three Paradigms Compared

You've now learned REST, RPC, and GraphQL individually—but how do you decide which to use? Each approach makes different trade-offs between complexity, flexibility, and use cases.

Core Trade-offs

REST

  • Complexity: Medium. Simple to start with standard HTTP, but resource modeling and HATEOAS can become complex.
  • Flexibility: Structured around resources. Works well when your domain maps cleanly to entities and CRUD operations.
  • Best for: Public APIs, resource-oriented systems, when HTTP caching matters, and when you need broad client compatibility.

RPC (especially gRPC)

  • Complexity: Higher upfront (requires IDL, tooling, code generation), but simpler for action-oriented APIs.
  • Flexibility: Action-focused, not resource-focused. Great when you're calling remote functions, not manipulating entities.
  • Best for: Internal microservices, high-performance scenarios, streaming data, when type safety and efficiency trump simplicity.

GraphQL

  • Complexity: Highest. Requires schema design, resolver implementation, and careful performance tuning (N+1 problems, complexity limits).
  • Flexibility: Maximum client flexibility—clients request exactly what they need. Server controls available data through schema.
  • Best for: Client-driven applications (mobile, SPAs), when you have diverse client needs, and when over-fetching/under-fetching is painful.

Think of It This Way

REST is like ordering from a fixed menu. RPC is like calling a specific chef to perform an action. GraphQL is like building your own custom meal from available ingredients.

Key Takeaway: Choose REST for resource-oriented public APIs, RPC for efficient internal service-to-service calls, and GraphQL when clients need flexible data fetching—but prepare for the complexity each choice brings.