System Design AI

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. In practice, I’ve seen a 30% reduction in latency when we added persisted query caching for a high-traffic analytics dashboard.

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. In practice, I set a max query cost of 500, which prevented a runaway query from consuming more than 0.5 % of our API capacity during peak traffic.

5. How does error handling differ?

REST uses HTTP status codes (404, 500, etc.) to convey errors, which clients can handle uniformly. GraphQL always returns a 200 OK, embedding errors in an errors array alongside partial data. 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 recent microservice migration, we used OpenAPI to generate SDKs for legacy services, then switched to GraphQL codegen for the new data-aggregation layer, cutting SDK maintenance effort by roughly 40%.

7. How do you measure performance impact?

I start by measuring request latency and throughput. For a typical e-commerce site, a REST endpoint returning a product with related reviews took about 120 ms and required two round trips. The equivalent GraphQL query took 80 ms with a single round trip. However, GraphQL’s resolver chain can add CPU overhead; we mitigated this by batching database calls and using DataLoader, which reduced resolver time 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

  1. Review the worked API gateway design in the System Design AI library, the layer where a REST or GraphQL API is exposed; note the diagram’s request-path breakdown.
  2. Draft your own answer on a canvas, using the same step-by-step format: start with the high-level choice, then dive into caching, versioning, and migration.
  3. Run through the nine questions aloud, timing each response to stay within 60-120 seconds, and ask the AI coach to review what you drew on the canvas.

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, often cutting latency by 30-40 % for composite pages.

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.