This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Apollo Client is a comprehensive caching GraphQL client for TypeScript/JavaScript. The project is maintained at version 4.x.x and uses a monorepo structure with npm workspaces.
npm run build- Build the entire projectnpm run build -w codegen- Build specific workspace (e.g., codegen)
npm test- Run all tests with Jestnpm run test:type-benches- Run type benchmarksnpm run test:memory- Run memory tests
npm run typecheck- Run TypeScript type checkingnpm run lint- Run ESLint with extended rulesnpm run format- Format code with Prettiernpm run check:format- Check if code is formatted correctlynpm run knip- Check for unused files/exportsnpm run madge- Check for circular dependencies
npm run extract-api- Generate API documentationnpm run typedoc- Generate TypeDoc documentationnpm run docmodel- Generate API documentation model
npx changeset- Create a changeset for your changes
-
Core (
src/core/) - Main Apollo Client implementationApolloClient.ts- Main client classObservableQuery.ts- Observable query implementationQueryManager.ts- Query lifecycle management
-
Cache (
src/cache/) - Caching layerinmemory/- InMemoryCache implementation (default cache)core/- Base cache abstractions
-
Link (
src/link/) - Network layer abstractionhttp/- HTTP link for GraphQL over HTTPbatch/- Batch link for combining querieserror/- Error handling linkschema/- Schema link for local executionws/- WebSocket link for subscriptions
-
React Integration (
src/react/) - React hooks and componentshooks/- React hooks (useQuery, useMutation, etc.)ssr/- Server-side rendering supportcontext/- React context providers
-
Utilities (
src/utilities/) - Shared utilitiesgraphql/- GraphQL document utilitiesinternal/- Internal utilitiesinvariant/- Error handling utilities
-
Testing (
src/testing/) - Testing utilitiescore/- Core testing utilitiesreact/- React testing utilities (MockedProvider)
-
Masking (
src/masking/) - Data masking for fragment colocation -
Local State (
src/local-state/) - Local state management
- Uses TypeScript 5.7.3 with strict mode enabled
- Module resolution: NodeNext
- Target: ESNext
- Separate tsconfig files for different purposes:
tsconfig.json- Main configurationtsconfig.build.json- Build configurationtsconfig.tests.json- Test configuration
- Jest with ts-jest for testing
- Custom test environment extending jsdom
- React Testing Library for React component tests
- Multiple React version testing (17, 18, 19)
- Coverage reporting with lcov
- Uses custom build script (
config/build.ts) - API Extractor for API documentation
- Size limit checking for bundle size
- Source map verification
- Publint for package publishing validation
- Exports - All public exports go through index files
- Internal APIs - Use
@apollo/client/*/internalpaths - Environment-specific builds - Production/development variants
- Type safety - Heavy use of TypeScript generics and type inference
- Reactive programming - Uses RxJS for observables
- Immutability - Emphasizes immutable data structures
- All changes require a changeset (
npx changeset) - PRs should include tests for bug fixes
- Follow existing code style (enforced by ESLint/Prettier)
- Large features need design discussion first
- Code review required from core contributors
- This is a monorepo with workspaces: main package, codegen, and codemods
- The project is currently at version 4.x.x (release candidate)
- Supports multiple peer dependencies (React 17/18/19, GraphQL 16)
- Uses patch-package for dependency patches
- Has extensive CI checks that must pass before merging
@.claude/documentation.md @.claude/hooks.md