categories.api-design Intermediate

GraphQL vs REST API: Core Differences and When to Choose GraphQL

AI Practice

GraphQL vs REST

REST

  • Resource-oriented; each endpoint represents a resource
  • Fixed response shape—prone to over-fetching or under-fetching
  • Multiple resources require multiple round trips
  • Native HTTP caching for GET requests

GraphQL

  • Schema-driven; single endpoint for all queries
  • Client specifies exactly which fields it needs
  • One request can combine multiple resources
  • Strongly-typed schema with built-in introspection

When to Choose

Scenario Recommendation
Multiple clients needing different data shapes GraphQL
Complex relational data GraphQL
Public third-party API REST
Simple CRUD service REST
Heavy HTTP / CDN caching REST

Common Pitfalls

  • N+1 Queries: use DataLoader for batched resolver calls
  • Security: limit query depth and complexity
  • Caching: POST-first breaks CDN cache; use Persisted Queries

Interview bonus: Mention GraphQL Federation for microservices and the BFF pattern.

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub