TECH_COMPARISON

React Query vs Apollo Client: REST Caching vs GraphQL Client

React Query is the go-to server state manager for REST APIs; Apollo Client is the dominant GraphQL client with normalized caching.

8 min readUpdated Jan 15, 2025
react-queryapollo-clientgraphqlrestcaching

Overview

React Query and Apollo Client are both data management libraries for React, but they are designed for different API paradigms. React Query is a general-purpose server state manager that works with any async function — REST, GraphQL, WebSockets, or custom protocols. Apollo Client is purpose-built for GraphQL, offering the deepest integration with GraphQL's type system, normalized caching, and subscriptions.

In practice, the choice between them often depends on whether your backend is GraphQL. If it is GraphQL, Apollo Client's investment in normalized caching and schema-aware tooling is a genuine advantage. If it is REST or mixed, React Query's simplicity and flexibility make it the better fit.

Key Technical Differences

Apollo Client's normalized cache (InMemoryCache) is its most powerful differentiating feature. It stores every queried entity by its __typename and id fields as cache keys. When a mutation updates a user object, Apollo automatically updates that entity everywhere it appears in the cache — in list queries, detail queries, and related queries — without manual cache invalidation. This normalized approach dramatically reduces stale UI bugs in applications with overlapping data queries.__

React Query's cache is organized by query keys rather than entity identity. Two queries that return overlapping data (a list of users and a single user detail) are cached separately. Keeping them in sync requires explicit invalidation. This is simpler to understand but can require more manual work for applications with complex overlapping data relationships.

Apollo Client supports GraphQL subscriptions natively via WebSocket transport (using graphql-ws or subscriptions-transport-ws), enabling real-time updates that integrate directly with the normalized cache. React Query has no built-in subscription support — real-time data requires integrating a WebSocket or SSE library separately and invalidating queries on events.

Performance & Scale

Apollo Client's normalized cache is highly memory-efficient for large datasets with many relationships — each entity is stored once regardless of how many queries include it. React Query stores complete query results per query key, which can mean storing the same entity multiple times if it appears in different queries. For applications with thousands of entities and complex relationship graphs, Apollo's normalized approach scales better in memory.

When to Choose Each

Choose React Query for REST APIs, mixed API environments, or any case where GraphQL's specific features are not available. Its simpler model, smaller bundle, and excellent developer experience make it the pragmatic default for most applications.

Choose Apollo Client when your API is GraphQL and you want the full depth of the GraphQL client ecosystem: normalized caching, subscriptions, field-level fetch policies, and the Apollo DevTools browser extension. Apollo is also the right choice when you use Apollo Federation on the server side.

Bottom Line

React Query wins for REST-based applications and teams that prioritize simplicity. Apollo Client wins for GraphQL-first architectures where normalized caching and subscription support provide meaningful benefits. Do not use Apollo for REST unless you have a specific reason — the added complexity is not justified.

GO DEEPER

Master this topic in our 12-week cohort

Our Advanced System Design cohort covers this and 11 other deep-dive topics with live sessions, assignments, and expert feedback.