REST vs GraphQL: Follow-Up Questions Interviewers Ask (and How to Answer)
Interviewers often ask a follow-up after you bring up REST versus GraphQL because the choice influences almost every layer of a system. They want to see whether you understand the practical trade-offs, not just the textbook definitions. A deep answer also reveals how you think about performance, developer experience, and long-term evolution.
The probing questions move from basic concepts toward system-wide implications. A senior candidate can discuss caching strategies and schema design; a staff candidate adds considerations like migration paths, observability, and cross-team governance.
Why interviewers probe the REST-GraphQL decision
Impact on API contract and client flexibility
The API style determines how tightly the client is coupled to the backend. REST endpoints expose fixed resources, while GraphQL lets the client request exactly what it needs. Interviewers ask to gauge whether you can balance flexibility with predictability.
Operational and architectural ripple effects
Choosing one over the other changes caching layers, monitoring, and deployment pipelines. Interviewers look for candidates who can anticipate these ripple effects and articulate concrete mitigation tactics.
Follow-up questions
1. How does caching differ between REST and GraphQL?
I would say that REST benefits from HTTP-level caching because each endpoint maps to a URL, so CDNs can store responses for, say, 60 seconds without extra work. With GraphQL, the query string is part of the request body, so typical HTTP caches miss. We usually add an in-memory cache like Apollo’s normalized cache on the client, and on the server we can use persisted query hashes to enable CDN caching for identical queries.
2. What about over-fetching and under-fetching?
In REST, each endpoint returns a fixed representation, so a mobile client often receives fields it never uses—over-fetching. Conversely, if the client needs extra data, we must call another endpoint—under-fetching. GraphQL solves both by letting the client specify fields, so a single query can retrieve exactly the needed data. For example, a product page that needed price, inventory, and reviews could be satisfied with one GraphQL query instead of three REST calls, cutting round-trip time from roughly 150 ms to 70 ms.
3. How do you handle versioning?
REST APIs usually version via the URL path (e.g., /v1/users). This adds maintenance overhead because every new version duplicates logic. GraphQL avoids explicit versioning; we evolve the schema by deprecating fields and adding new ones. Clients that still request deprecated fields continue to work, while newer clients can adopt the additions. In a recent project, we removed a field after two years of deprecation without breaking any client, whereas a REST version change required a coordinated rollout across three services.
4. What are the security implications?
Both styles need authentication and authorization, but GraphQL introduces a risk of overly broad queries that could pull massive amounts of data. We mitigate this with query depth limits and cost analysis—e.g., rejecting any query with depth > 5 or cost > 1,000. REST can rely on endpoint-level permissions, which are simpler to audit.
5. How does error handling differ?
REST uses HTTP status codes (404, 500, etc.) to convey errors, which clients can handle uniformly. GraphQL servers usually return 200 OK even when resolvers fail, embedding errors in an errors array alongside partial data (requests that fail to parse or validate often get a 4xx). This means the client must inspect the response body for failures. I usually map GraphQL errors to a custom code field so the UI can display user-friendly messages, while still logging the original exception for debugging.
6. What tooling support exists for each?
REST benefits from mature tools like Swagger/OpenAPI for documentation and client generation. GraphQL has its own ecosystem: schema introspection, GraphiQL/Playground for interactive exploration, and code generators like Apollo Codegen. In a migration, you might keep OpenAPI-generated SDKs for the legacy services and use GraphQL codegen for the new data-aggregation layer.
7. How do you measure performance impact?
I start by measuring request latency and throughput. Say a REST endpoint returning a product with related reviews takes about 120 ms over two round trips, and the equivalent GraphQL query takes 80 ms in one. However, GraphQL’s resolver chain can add CPU overhead; batching database calls with DataLoader can cut resolver time sharply (say, from 30 ms to 12 ms per request).
8. How would you migrate an existing REST API to GraphQL?
First, I would identify high-traffic use cases that suffer from over-fetching. Then I’d create a GraphQL gateway that stitches existing REST services behind resolvers, using persisted queries to keep caching benefits. Once the gateway is stable, I’d gradually deprecate the old endpoints, providing both APIs during a transition window of about six months. Monitoring would focus on error rates and latency to ensure the new layer does not introduce regressions.
9. When might REST still be the better choice?
If the client is a simple script or third-party integration that needs a stable contract, REST’s explicit URLs and status codes are easier to consume. Also, when you need aggressive edge caching—like serving static assets or public feeds—REST’s CDN friendliness shines. In a recent IoT telemetry pipeline, we kept a thin REST endpoint for device registration because the devices could not handle the overhead of GraphQL query construction.
Senior vs. Staff answers
A senior answer will correctly enumerate trade-offs, provide concrete numbers, and show awareness of tooling. A staff answer goes further: it frames the decision in terms of organization-wide impact, discusses migration governance, observability, and cost modeling. Staff candidates also anticipate future scaling scenarios, such as how a GraphQL schema will evolve when dozens of teams start adding fields, and propose governance processes to avoid schema bloat.
How to practice this
- Read the free worked design, Design an API Gateway, the layer where a REST or GraphQL API is exposed; note the diagram’s request-path breakdown.
- Draft your own answer on paper or a whiteboard, using the same step-by-step format: start with the high-level choice, then dive into caching, versioning, and migration.
- Run through the nine questions aloud, timing each response to stay within 60-120 seconds, then compare your sketch with the worked API gateway design.
Questions people ask
What is the biggest performance advantage of GraphQL over REST?
GraphQL can reduce round-trip latency by consolidating multiple resource fetches into a single request, which matters most for composite pages on high-latency mobile networks.
Can GraphQL be cached at the edge like REST?
Yes, using persisted query hashes and CDN-friendly URLs; this approach can achieve similar cache-hit rates as REST when query patterns are stable.
How do you prevent a GraphQL query from becoming too expensive?
Implement depth limits and query-cost analysis, rejecting queries that exceed predefined thresholds (e.g., depth > 5 or cost > 1,000).
When should I stick with REST for a new service?
Choose REST when the client is a simple consumer, when you need aggressive CDN caching, or when the API contract must remain immutable for external partners.