Q2: How does GraphQL differ from a traditional REST API?

Difficulty:EasyTopic:Architecture

In REST, endpoints represent resources (e.g., /users, /posts), and data structure is fixed by the server. GraphQL uses a single endpoint (typically /graphql) where clients post a structured query specifying the exact response shape.

REST vs GraphQL Comparison
Endpoints: Multiple resource URIs
REST requires multiple network calls for relational data.
GraphQL Endpoints: Single endpoint
GraphQL executes complex declarative queries at one endpoint.
Data Fetching: Server defines payload
REST payload structure is static.
GraphQL Data Fetching: Client defines payload
GraphQL response reflects requested schema fields.
Key Takeaways
  • REST relies on multiple resource endpoints, while GraphQL operates over a single endpoint.
  • GraphQL gives the client total control over response shape.
Knowledge Check

What is the typical network architecture for a standard GraphQL server?