
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@apollo/client-codemod-migrate-3-to-4
Advanced tools
Apollo Client Codemod to migrate from version 3 to version 4
You can run this codemod with the following command:
npx @apollo/client-codemod-migrate-3-to-4 --parser ts file1.ts file2.ts
if you want to only run a specific codemod:
npx @apollo/client-codemod-migrate-3-to-4 --parser ts file1.ts file2.ts --codemod imports
In the order they will be applied per default if you don't manually specify a codemod:
legacyEntryPoints: Moves imports from old legacy entry points like @apollo/client/main.cjs or @apollo/client/react/react.cjs to the new entry points like @apollo/client or @apollo/client/react.imports: Moves imports that have been moved or renamed in Apollo Client 4. Also moves types into namespace imports where applicable.links: Moves split, from, concat and empty onto the ApolloLink namespace, changes funtion link invocations like createHttpLink(...) to their class equivalents like (new HttpLink(...)).
Does not change setContext((operation, prevContext) => {}) to new ContextLink((prevContext, operation) => {}) - this requires manual intervention, as the order of callback arguments is flipped and this is not reliable codemoddable.removals: Points all imports of values or types that have been removed in Apollo Client 4 to the @apollo/client/v4-migration entry point. That entry point contains context for each removal, oftentimes with migration instructions.clientSetup: Applies the following steps from the migration guide to your Apollo Client setup code
uri, headers and credentials to the link option and creates a new HttpLink instancename and version into a clientAwareness optionlocalState option with a new LocalState instance, moves resolvers, and removes typeDefs and fragmentMatcher optionsconnectToDevTools option to devtools.enableddisableNetworkFetches to prioritizeCacheValuesdataMasking is enabled, adds a template for global type augmentation to re-enable data masking typesincrementalHandler option and adds a template for global type augmentation to accordingly type network responses in custom linksTCacheShape type argument from all ApolloClient usages (types and constructor calls)There is some syntax overlap between TypeScript and TypeScript-JSX files, so you might need to run the Codemod against both file extensions sepearately to avoid errors:
npx @apollo/client-codemod-migrate-3-to-4 --parser ts --ignore-pattern="*.{tsx,d.ts}" file1.ts file2.ts
npx @apollo/client-codemod-migrate-3-to-4 --parser tsx --ignore-pattern="*.ts" file1.ts file2.ts
npx https://pkg.pr.new/apollographql/apollo-client/@apollo/client-codemod-migrate-3-to-4@12733 --parser ts file1.ts file2.ts
FAQs
Apollo Client Codemod to migrate from version 3 to version 4
The npm package @apollo/client-codemod-migrate-3-to-4 receives a total of 468 weekly downloads. As such, @apollo/client-codemod-migrate-3-to-4 popularity was classified as not popular.
We found that @apollo/client-codemod-migrate-3-to-4 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.