{"id":25653,"library":"graphql-codegen-compiler","title":"GraphQL Codegen Compiler (legacy v0.x)","description":"This package is the legacy compiler engine for GraphQL Code Generator v0.x, used to process GraphQL schemas and generate TypeScript types, React hooks, or other artifacts. The current stable version is 0.13.0, which is part of the now-deprecated v0.x line. It was replaced by `@graphql-codegen/cli` and `@graphql-codegen/plugin-helpers` in GraphQL Code Generator v1+, which introduced a new plugin-based architecture. This compiler is not compatible with v1+ plugins and should not be used in new projects. Key differentiator: it is a monolithic compiler that takes a schema and outputs code through a single pipeline, unlike the modular v1+ system that uses independent plugins.","status":"deprecated","version":"0.13.0","language":"javascript","source_language":"en","source_url":"git@github.com:dotansimha/graphql-code-generator","tags":["javascript","typescript"],"install":[{"cmd":"npm install graphql-codegen-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-codegen-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-codegen-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for parsing and validating GraphQL schemas","package":"graphql","optional":false}],"imports":[{"note":"The package exports a single default class. CommonJS require would be `const GraphQLCodegenCompiler = require('graphql-codegen-compiler').default;` (though the package does not provide a CJS default export).","wrong":"const { GraphQLCodegenCompiler } = require('graphql-codegen-compiler');","symbol":"default (GraphQLCodegenCompiler)","correct":"import GraphQLCodegenCompiler from 'graphql-codegen-compiler';"},{"note":"CompilerOptions is a TypeScript type, not a runtime value. Use `import type` for type-only imports.","wrong":"import { CompilerOptions } from 'graphql-codegen-compiler';","symbol":"CompilerOptions","correct":"import type { CompilerOptions } from 'graphql-codegen-compiler';"},{"note":"The `compile` function is a named export, not a method on the default export. It cannot be destructured from the default import.","wrong":"import GraphQLCodegenCompiler, { compile } from 'graphql-codegen-compiler';","symbol":"compile","correct":"import { compile } from 'graphql-codegen-compiler';"}],"quickstart":{"code":"import GraphQLCodegenCompiler from 'graphql-codegen-compiler';\nimport { buildSchema } from 'graphql';\n\nconst schema = buildSchema(`\n  type Query {\n    hello: String\n  }\n`);\n\nconst compiler = new GraphQLCodegenCompiler();\nconst result = compiler.compile(schema, {\n  output: 'typescript',\n  plugins: [],\n  documents: '',\n  config: { namingConvention: 'keep' }\n});\n\nconsole.log(result);","lang":"typescript","description":"Creates a GraphQLCodegenCompiler instance, builds a schema, compiles it to TypeScript types."},"warnings":[{"fix":"Migrate to GraphQL Code Generator v1+ using `@graphql-codegen/cli` and the appropriate plugins (e.g., `@graphql-codegen/typescript`).","message":"graphql-codegen-compiler is deprecated. Use @graphql-codegen/cli and @graphql-codegen/plugin-helpers instead.","severity":"deprecated","affected_versions":">=0.0.1"},{"fix":"Always provide an array for the 'plugins' option, even if empty.","message":"The 'compile' method signature changed between minor versions; 'plugins' option is now required.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Pin graphql@14 as a dependency when using this compiler.","message":"This package does not support GraphQL v15+ validation rules correctly; use graphql@14 for consistent behavior.","severity":"gotcha","affected_versions":">=0.13.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `const GraphQLCodegenCompiler = require('graphql-codegen-compiler');` then call `new GraphQLCodegenCompiler().compile(...)`.","cause":"Default import does not include the compile function; likely used `const { compile } = require('graphql-codegen-compiler')` which returns the default class, not an object.","error":"TypeError: compiler.compile is not a function"},{"fix":"Run `npm install graphql-codegen-compiler graphql@14` and use import syntax (ESM) or `const X = require('graphql-codegen-compiler').default` (CJS fallback).","cause":"Package is not installed, or installed but Node.js cannot resolve it (e.g., ESM package required import).","error":"Error: Cannot find module 'graphql-codegen-compiler'"},{"fix":"Use `buildSchema()` from 'graphql' to convert your schema definition to a GraphQLSchema object before passing to compile.","cause":"Passed a schema string or document node instead of a GraphQLSchema object.","error":"TypeError: schema is not a valid GraphQL schema"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}