REST vs GraphQL: what is the difference?
REST and GraphQL are two approaches to building APIs. REST exposes multiple endpoints, each returning a fixed data shape — fetching a user and their posts might mean two or three round trips, and you often get back more fields than you need (over-fetching) or too few (under-fetching).
GraphQL exposes a single endpoint where the client specifies exactly which fields it wants in one query, so you fetch precisely the data you need in a single request. This makes GraphQL attractive for complex, nested data and for mobile clients where round trips are expensive.
The trade-offs: REST is simpler, cacheable at the HTTP layer, and ubiquitous; GraphQL adds flexibility but moves complexity to the server (resolvers, query-cost limiting, caching). A strong interview answer names the core difference — fixed endpoints vs a flexible query language — and then the trade-off: REST for simple, cacheable resources; GraphQL when clients need varied, nested data without over-fetching.