@apollo/client-codemod-migrate-3-to-4@1.0.0-rc.3
Breaking Changes📦 apollo-clientView on GitHub →
⚠ 6 breaking✨ 2 features⚡ 1 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
- Run the new `clientSetup` codemod (e.g., `npx apollo clientSetup`) to automatically apply the configuration changes.
- If not using the codemod, manually move `uri`, `headers`, and `credentials` into a `link` option with a new `HttpLink` instance.
- Move `name` and `version` into a `clientAwareness` option.
- Replace removed `typeDefs` and `fragmentMatcher` options with a `localState` option containing a `LocalState` instance and relocate `resolvers`.
- Rename `connectToDevTools` to `devtools.enabled` and `disableNetworkFetches` to `prioritizeCacheValues`.
- If `dataMasking` is enabled, add the provided global type augmentation template.
- If using custom links, add the `incrementalHandler` option and the corresponding type augmentation template.
- 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.