npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@apollo/client-codemod-migrate-3-to-4

v1.0.2

Published

Apollo Client Codemod to migrate from version 3 to version 4

Readme

Using this codemod

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

Available codemods:

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
    • Moves uri, headers and credentials to the link option and creates a new HttpLink instance
    • Moves name and version into a clientAwareness option
    • Adds a localState option with a new LocalState instance, moves resolvers, and removes typeDefs and fragmentMatcher options
    • Changes the connectToDevTools option to devtools.enabled
    • Renames disableNetworkFetches to prioritizeCacheValues
    • If dataMasking is enabled, adds a template for global type augmentation to re-enable data masking types
    • Adds the incrementalHandler option and adds a template for global type augmentation to accordingly type network responses in custom links
    • Removes the TCacheShape type argument from all ApolloClient usages (types and constructor calls)

Usage against TypeScript/TSX

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

Using the Codemod from a specific PR

npx https://pkg.pr.new/apollographql/apollo-client/@apollo/client-codemod-migrate-3-to-4@12733 --parser ts file1.ts file2.ts