Apollo Client
Industry-leading GraphQL client with normalized caching for TypeScript and React
Repository Health
Technical Analysis
Apollo Client is a comprehensive GraphQL client for TypeScript, JavaScript, React, Vue, Angular, and other frameworks, providing everything an application needs to fetch, cache, and update data from a GraphQL API. Its centerpiece is a normalized, in-memory cache that automatically keeps every query and mutation result consistent — updating any component observing affected data as soon as a mutation or subscription changes it, without manual cache-busting.
Beyond data fetching, Apollo Client bundles a link-based network layer (for batching, retries, auth, and error handling), optimistic UI helpers, local-state management, and official React hooks (useQuery, useMutation, useSubscription) that integrate cache state directly into component render cycles. It’s maintained by Apollo GraphQL and is one of the two dominant GraphQL client choices (alongside Relay) for production JavaScript applications.
What You Get
- A normalized in-memory cache (
InMemoryCache) that deduplicates and keeps entities consistent across every query/mutation - React hooks (
useQuery,useMutation,useSubscription,useLazyQuery) with built-in loading/error state - A composable
ApolloLinknetwork layer for auth headers, batching, retries, and error handling - Optimistic UI updates and automatic cache updates after mutations
- Local-state management for combining client-only state with remote GraphQL data in the same cache
- Official bindings/adapters beyond React, plus first-class TypeScript types generated from your schema
Common Use Cases
- Fetching and caching data from a GraphQL API in a React (or Vue/Angular) single-page application
- Building optimistic UI flows where mutations update the interface instantly before server confirmation
- Keeping multiple components in sync automatically when shared data changes via mutations or subscriptions
- Combining local client-only state (UI flags, drafts) with server data through the same query/cache layer
Under The Hood
Architecture The client is organized around src/core/ (including QueryManager.ts at ~1,840 lines, the central orchestrator that tracks in-flight queries, deduplicates requests, and notifies observers of cache changes) and src/cache/inmemory/inMemoryCache.ts (~610 lines), which implements the normalized cache using object identity fields (id/__typename by default, or custom keyFields) to store every entity once regardless of how many queries touched it. src/link/ implements the Apollo Link architecture — a chain-of-responsibility pattern where each link (HTTP, retry, error, auth) can inspect or transform the operation before passing it to the next link, terminating in an HTTP link that performs the actual network request. src/react/ layers hooks and context providers on top of this core, subscribing components to cache changes so useQuery results update reactively, while src/local-state/ and src/masking/ implement client-only fields and fragment data masking respectively. Tech Stack TypeScript, published as @apollo/client (a scoped package superseding the legacy unscoped apollo-client), with graphql as a peer dependency and Zen Observable/RxJS-adjacent observables internally for the subscription/link pipeline; the monorepo uses a private root package with per-target build outputs (CJS, ESM) under dist/. Code Quality Test coverage is extensive with 136+ .test.ts files under src/, covering the cache, query manager, links, and React hooks individually, backed by CI (CircleCI badge in the README) and a documented issue triage/community process (Discourse community link). API Design The hook-based API (useQuery(GET_ITEMS)) is deliberately close to native GraphQL syntax and requires minimal boilerplate to get a query rendering with loading/error handling, though correctly configuring cache normalization (keyFields, type policies) for complex schemas is where the learning curve rises.
Used by 22 apps in this directory
Webiny JS
Blogging · CMS · Ecommerce
Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.
Wiki.js
Collaboration · Knowledge Management
A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.
Wiki.js
Collaboration · Knowledge Management
A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.
Wiki.js
Collaboration · Knowledge Management
A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.