{"id":12765,"library":"apollo-codegen-typescript","title":"Apollo Codegen TypeScript Generator","description":"Apollo Codegen TypeScript Generator is an internal module of the now-deprecated `apollographql/apollo-tooling` monorepo. Its primary function was to facilitate the generation of TypeScript types from GraphQL schemas and operation documents, predominantly via the `apollo client:codegen` CLI command. The package's last version, 0.40.9, was released around 2020. This package, and the `apollo` CLI commands it powered, are no longer actively maintained. Apollo has officially deprecated `apollo client:codegen`, directing users to adopt `GraphQL Code Generator` for type generation. This shift marks the end of its release cadence and dedicated support. Its key differentiator was its deep integration within the Apollo CLI ecosystem, providing a streamlined, opinionated approach to type generation for Apollo Client users. However, this opinionated nature also meant less flexibility compared to more customizable alternatives like `GraphQL Code Generator`.","status":"abandoned","version":"0.40.9","language":"javascript","source_language":"en","source_url":"https://github.com/apollographql/apollo-tooling","tags":["javascript","typescript"],"install":[{"cmd":"npm install apollo-codegen-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add apollo-codegen-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add apollo-codegen-typescript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for GraphQL schema parsing and type definition.","package":"graphql","optional":false},{"reason":"Required to generate TypeScript output.","package":"typescript","optional":false}],"imports":[{"note":"This package was primarily an internal module for the Apollo CLI. Direct programmatic use by end-users was uncommon and is highly discouraged due to its abandoned status. Apollo recommends `GraphQL Code Generator` instead.","wrong":"const generate = require('apollo-codegen-typescript');","symbol":"generate","correct":"// Direct programmatic import is not recommended as this package is abandoned.\n// Most users interacted via the Apollo CLI. If you absolutely must, it would be:\n// import { generate } from 'apollo-codegen-typescript';"}],"quickstart":{"code":"/*\nThis quickstart demonstrates the historical usage of Apollo Codegen via the Apollo CLI.\nThis command and the underlying tooling are now deprecated and abandoned.\n\nRecommended alternative: GraphQL Code Generator (https://www.graphql-code-generator.com/)\n*/\n\n// 1. Install the (now deprecated) Apollo CLI globally or locally\n// npm install -g apollo@2 # Or use npx for one-off execution\n\n// 2. Define your GraphQL schema (e.g., schema.graphql or introspect from a URL)\n// For demonstration, let's create a dummy schema.graphql\n// You would typically replace this with your actual schema.\n// echo 'type Query { hello: String }' > schema.graphql\n\n// 3. Define your GraphQL operations (e.g., in a .tsx or .graphql file)\n// For this example, let's assume you have a query in src/MyComponent.tsx:\n// import { gql } from '@apollo/client';\n// const HELLO_QUERY = gql`query HelloQuery { hello }`;\n\n// 4. Run the deprecated codegen command to generate TypeScript types\n// This command assumes a schema.graphql file and operations in src/**/*.tsx\n// It will output types to 'types' directory and a global types file.\nnpx apollo codegen:generate \\\n  --localSchemaFile=schema.graphql \\\n  --target=typescript \\\n  --includes=src/**/*.tsx \\\n  --tagName=gql \\\n  --addTypename \\\n  --globalTypesFile=src/types/global-types.ts \\\n  types\n\nconsole.log(\"If successful, TypeScript types for your GraphQL operations would be generated.\");\nconsole.log(\"Remember, this tool is deprecated. Migrate to GraphQL Code Generator.\");","lang":"typescript","description":"Demonstrates the historical usage of the `apollo client:codegen` CLI command to generate TypeScript types from a GraphQL schema and operations, highlighting its deprecation."},"warnings":[{"fix":"Migrate your code generation workflow to `GraphQL Code Generator`. This requires reconfiguring your project to use `graphql-code-generator` CLI and its plugins (e.g., `@graphql-codegen/cli`, `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations`).","message":"The `apollo client:codegen` command, which was the primary way to use this module, has been officially deprecated. The entire `apollo-tooling` repository is in maintenance mode and slated for full deprecation.","severity":"breaking","affected_versions":">=0.40.9 (and all versions of apollo-tooling)"},{"fix":"Transition to actively maintained alternatives like `GraphQL Code Generator` to ensure security patches and ongoing support.","message":"This package is no longer actively maintained. Security vulnerabilities and bug fixes are unlikely to be addressed. Using it in production environments is risky due to potential unpatched issues.","severity":"gotcha","affected_versions":">=0.40.9"},{"fix":"Use `GraphQL Code Generator`, which is actively maintained and regularly updated to support the latest versions of GraphQL, TypeScript, and Node.js.","message":"Compatibility issues may arise with newer versions of Node.js, TypeScript, or the `graphql` library due to lack of updates. The package's last release (0.40.9) is from around 2020.","severity":"gotcha","affected_versions":">=0.40.9"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your `package.json` scripts to use `graphql-code-generator` CLI instead. Consult the GraphQL Code Generator documentation for migration guides.","cause":"Attempting to use the `apollo codegen:generate` command from a recent or deprecated version of the Apollo CLI.","error":"Error: Command 'codegen' is deprecated."},{"fix":"Avoid direct imports. If you need GraphQL type generation, use `GraphQL Code Generator` and install its relevant packages (e.g., `@graphql-codegen/cli`).","cause":"This package is an internal module of `apollo-tooling` and not intended for direct installation or import by most applications. It's likely you're trying to use it in a way it wasn't designed for, or it's simply not installed as a dependency.","error":"Cannot find module 'apollo-codegen-typescript'"},{"fix":"Ensure your GraphQL schema and operation documents are valid. More importantly, migrate to `GraphQL Code Generator` to benefit from modern GraphQL spec support and active maintenance.","cause":"This error often occurs when the `apollo-codegen-typescript` module, or the `apollo` CLI, encounters an invalid or unexpected GraphQL schema or operation definition that it cannot parse, especially with newer GraphQL features it doesn't support.","error":"TypeError: Cannot read property 'kind' of undefined"}],"ecosystem":"npm"}