Change8

@apollo/client-codemod-migrate-3-to-4@1.0.0-rc.3

Breaking Changes
📦 apollo-clientView on GitHub →
6 breaking2 features1 deprecations🔧 9 symbols

Summary

Apollo Client introduces a `clientSetup` codemod to restructure client configuration and a `legacyEntryPoints` transformation to update import paths, requiring updates to option names, removed settings, and import statements.

⚠️ Breaking Changes

  • Options `uri`, `headers` and `credentials` are no longer top-level; they must be moved into a `link` option with a new `HttpLink` instance.
  • `name` and `version` options have been moved into a `clientAwareness` option.
  • `typeDefs` and `fragmentMatcher` options have been removed; use `localState` with a `LocalState` instance and move `resolvers` accordingly.
  • `connectToDevTools` option has been renamed to `devtools.enabled`.
  • `disableNetworkFetches` option has been renamed to `prioritizeCacheValues`.
  • Imports from legacy entry points such as `@apollo/client/main.cjs` or `@apollo/client/react/react.cjs` must be updated to the new entry points `@apollo/client` or `@apollo/client/react`.

Migration Steps

  1. Run the new `clientSetup` codemod (e.g., `npx apollo clientSetup`) to automatically apply the configuration changes.
  2. If not using the codemod, manually move `uri`, `headers`, and `credentials` into a `link` option with a new `HttpLink` instance.
  3. Move `name` and `version` into a `clientAwareness` option.
  4. Replace removed `typeDefs` and `fragmentMatcher` options with a `localState` option containing a `LocalState` instance and relocate `resolvers`.
  5. Rename `connectToDevTools` to `devtools.enabled` and `disableNetworkFetches` to `prioritizeCacheValues`.
  6. If `dataMasking` is enabled, add the provided global type augmentation template.
  7. If using custom links, add the `incrementalHandler` option and the corresponding type augmentation template.
  8. Run the `legacyEntryPoints` transformation (or update import statements) to replace legacy entry point paths with the new ones.

✨ New Features

  • Added a `clientSetup` codemod step that automates migration of Apollo Client configuration (link, clientAwareness, localState, devtools, etc.).
  • Added a `legacyEntryPoints` transformation step that rewrites imports from old legacy entry points to the new package entry points.

🔧 Affected Symbols

HttpLinkLocalStateclientAwarenessdevtools.enabledprioritizeCacheValues@apollo/client/main.cjs@apollo/client/react/react.cjs@apollo/client@apollo/client/react

⚡ Deprecations

  • `typeDefs` and `fragmentMatcher` options are deprecated and have been removed in this release.