⬡ GraphQL Beginner

What is the difference between GraphQL and REST?

Answer

REST exposes multiple endpoints (e.g., /users, /posts), each returning a fixed data shape — leading to over-fetching (getting more data than needed) or under-fetching (requiring multiple requests). GraphQL exposes a single endpoint and lets the client declare exactly what fields it needs in the query. This eliminates over-fetching and solves under-fetching with nested queries. REST uses HTTP verbs (GET, POST, PUT, DELETE) for semantics; GraphQL uses query/mutation/subscription operation types. GraphQL also provides a strongly-typed schema that serves as a contract between client and server.