Explain the differences between REST and GraphQL APIs from a JavaScript client perspective.
Instruction: Discuss the conceptual differences between REST and GraphQL, and their implications when consumed by a JavaScript application.
Context: This question assesses the candidate's understanding of web API consumption in JavaScript applications, focusing on the differences between RESTful services and GraphQL.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
REST is an architectural style commonly implemented with HTTP resources, methods and representations. GraphQL is a query language and execution system in which clients select fields exposed by a typed schema. Neither choice makes the JavaScript client or server automatically faster.
For a profile screen, a REST API might expose a profile resource and a separate recent-posts resource, or provide a purpose-built combined representation...