Apollo GraphQL has announced Apollo Client 4.0, a major version that brings a leaner architecture, tighter TypeScript integration, framework-agnostic APIs, and more modular feature opt-ins, all designed to reduce bundle size and improve developer experience.
One of the headline changes is support for opt-in feature inclusion. Features like local state management (@client directives) and the default HTTP link are no longer bundled unless explicitly imported. Combined with modern target transpilation (for browsers since ~2023 and Node.js 20+), better ESM support, and improved tree-shaking, many users should see a 20-30% reduction in the bundle size contribution from Apollo Client.
On the TypeScript front, 4.0 introduces colocated/namespace types (e.g. useQuery.Options
and useQuery.Result
), stricter enforcement of required variables, a new dataState
property to distinguish query states (empty, partial, streaming, complete), and module-augmentation for customizing context types instead of using fragile generics. These changes aim to reduce type errors and improve discoverability of types during everyday use.
In addition, error handling has been improved. The monolithic ApolloError has been replaced or decomposed into more specific error classes that allow clearer distinctions (GraphQL vs network vs parsing), and new static .is()
type check methods to help with narrowing.
The core library has been decoupled from React. React-specific exports now live in @apollo/client/react
. This makes it clearer when you’re using React hooks vs when you’re using core GraphQL client logic in non-React environments, and reduces unnecessary dependencies for usages outside of React.
Early feedback from the community has been good. One user on X shared: This has been amazing for my team so far
, in response to the GA version release post.
On reddit, a commenter asked for the recommended approach for types when migrating from v3 to v4, with the maintainer responding with signposting to the migration guide and the following advice:
Generally, we recommend against generated hooks and encourage to use TypedDocumentNode instead – either by setting up the typed-document-node codegen plugin, or by using the client preset, but with a modified configuration.
For teams considering migration, Apollo provides a detailed migration guide. Key breaking changes include updating imports for React vs core usage, adapting to the new dataState API, handling error class changes, and introducing RxJS as a peer dependency.
There is a codemod available which the authors claim will get you 90% migrated in minutes, just by running the following command in a project:
npx @apollo/client-codemod-migrate-3-to-4 src
Apollo Client is an open-source GraphQL client maintained by Apollo GraphQL. It provides tools for managing queries, caching, mutations, and subscriptions across JavaScript and TypeScript applications, with first-class support for React and integration into a wide range of frameworks.