Registry / serialization / graphql-codegen-compiler

graphql-codegen-compiler

JSON →
library0.13.0jsnpmunverified

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.

npm install graphql-codegen-compiler
INSTALL
IMPORT
SIG · GRAPHQL-CODEGEN-CO
G
graphql-codegen-compiler
serializationjavascriptv0.13.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (GraphQLCodegenCompiler)
import GraphQLCodegenCompiler from 'graphql-codegen-compiler';
const { GraphQLCodegenCompiler } = require('graphql-codegen-compiler');
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).
CompilerOptions
import type { CompilerOptions } from 'graphql-codegen-compiler';
import { CompilerOptions } from 'graphql-codegen-compiler';
CompilerOptions is a TypeScript type, not a runtime value. Use `import type` for type-only imports.
compile
import { compile } from 'graphql-codegen-compiler';
import GraphQLCodegenCompiler, { compile } from 'graphql-codegen-compiler';
The `compile` function is a named export, not a method on the default export. It cannot be destructured from the default import.

Creates a GraphQLCodegenCompiler instance, builds a schema, compiles it to TypeScript types.

import GraphQLCodegenCompiler from 'graphql-codegen-compiler'; import { buildSchema } from 'graphql'; const schema = buildSchema(` type Query { hello: String } `); const compiler = new GraphQLCodegenCompiler(); const result = compiler.compile(schema, { output: 'typescript', plugins: [], documents: '', config: { namingConvention: 'keep' } }); console.log(result);
Debug
Known issues
deprecatedgraphql-codegen-compiler is deprecated. Use @graphql-codegen/cli and @graphql-codegen/plugin-helpers instead.
fix
Migrate to GraphQL Code Generator v1+ using `@graphql-codegen/cli` and the appropriate plugins (e.g., `@graphql-codegen/typescript`).
affects: >=0.0.1
breakingThe 'compile' method signature changed between minor versions; 'plugins' option is now required.
fix
Always provide an array for the 'plugins' option, even if empty.
affects: >=0.10.0
gotchaThis package does not support GraphQL v15+ validation rules correctly; use graphql@14 for consistent behavior.
fix
Pin graphql@14 as a dependency when using this compiler.
affects: >=0.13.0
Errors
Common errors & fixes
TypeError: compiler.compile is not a function
Default import does not include the compile function; likely used `const { compile } = require('graphql-codegen-compiler')` which returns the default class, not an object.
fix
Use `const GraphQLCodegenCompiler = require('graphql-codegen-compiler');` then call `new GraphQLCodegenCompiler().compile(...)`.
Error: Cannot find module 'graphql-codegen-compiler'
Package is not installed, or installed but Node.js cannot resolve it (e.g., ESM package required import).
fix
Run `npm install graphql-codegen-compiler graphql@14` and use import syntax (ESM) or `const X = require('graphql-codegen-compiler').default` (CJS fallback).
TypeError: schema is not a valid GraphQL schema
Passed a schema string or document node instead of a GraphQLSchema object.
fix
Use `buildSchema()` from 'graphql' to convert your schema definition to a GraphQLSchema object before passing to compile.
Upgrade
Version history
0.13.0latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency for parsing and validating GraphQL schemas
Agent activity
4 hits · last 30 days
node
4
Resources
graphql-codegen-compiler — npm install graphql-codegen-compiler · libregistry