GraphQL lets clients specify exactly what data they want in one request, reducing over-fetching and under-fetching. REST typically uses multiple endpoints, which may require several requests.
REST APIs often use version numbers in URLs to manage changes. GraphQL encourages evolving the schema by adding new fields and deprecating old ones without versioning.
{ user(id: "1") { name, posts { title } } }What is the expected shape of the JSON response?
GraphQL responses wrap the requested data inside a 'data' object. The shape matches the query structure exactly.
query { user(id: "1") { name posts { title } } }GraphQL requires commas between fields in selection sets. Missing commas cause syntax errors.
GraphQL lets clients request related data in one query, reducing the number of network calls compared to REST which requires multiple endpoints.
