Registry / devops / graphql-codegen-generators

graphql-codegen-generators

JSON →
library0.8.21jsnpmunverified

Built-in generators (templates) for GraphQL Code Generator v0.8.21, specifically TypeScript single-file and multiple-file output. This package is part of the legacy `graphql-code-generator` ecosystem (pre-v1), which has been superseded by `@graphql-codegen/cli` and `@graphql-codegen/typescript`. It provides Handlebars-based templates for generating TypeScript types from GraphQL schemas. Release cadence: no longer updated; last release 0.8.21. Key differentiators: enables custom generators by implementing the `GeneratorConfig` interface and using Handlebars templates, with support for both single and multi-file output.

npm install graphql-codegen-generators
INSTALL
IMPORT
SIG · GRAPHQL-CODEGEN-GE
G
graphql-codegen-generators
devopsjavascriptv0.8.21
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.

GeneratorConfig
import { GeneratorConfig } from 'graphql-codegen-generators';
import { GeneratorConfig } from 'graphql-codegen-core';
Interface for defining a generator configuration, exported from this package.
EInputType
import { EInputType } from 'graphql-codegen-generators';
import { EInputType } from 'graphql-codegen-core';
Enum with values SINGLE_FILE and MULTIPLE_FILES.
types
import { types } from 'graphql-codegen-generators';
import types from 'graphql-codegen-generators';
Named export containing all generator templates (TypeScript single and multiple files). Also available as named exports 'typescript' and 'typescript-multiple'.

Demonstrates using the built-in TypeScript single-file generator with a minimal GraphQL schema.

import { types } from 'graphql-codegen-generators'; import { generate } from 'graphql-codegen-core'; import { buildSchema } from 'graphql'; const schema = buildSchema(` type Query { hello: String } `); const result = generate({ schema: schema, templates: types, }); console.log(result); // generated TypeScript code as string
Debug
Known issues
deprecatedThis package is part of the deprecated graphql-code-generator v0.x ecosystem. Use @graphql-codegen/cli and @graphql-codegen/typescript instead.
fix
Migrate to the official GraphQL Code Generator v1+ (https://the-guild.dev/graphql/codegen). Replace `graphql-codegen-generators` with `@graphql-codegen/typescript` and use `@graphql-codegen/cli`.
affects: >=0.8.21
breakingVersion 0.8.x uses Handlebars templates; custom generators must follow the old GeneratorConfig interface, which changed in v1.
fix
If upgrading to v1, rewrite custom generators using the new plugin API (https://the-guild.dev/graphql/codegen/docs/custom-codegen).
affects: >=0.8.0
gotchaThe build process requires Webpack with awesome-typescript-loader and raw-loader to compile templates. Manual template loading is not supported.
fix
Use the provided build scripts (yarn build) or import the pre-built package. Do not attempt to load templates at runtime.
affects: >=0.8.0
gotchaEInputType.SINGLE_FILE requires an 'index' template and 'outFile' property in config. MULTIPLE_FILES requires templates for each context and a 'filesExtension'.
fix
Refer to the README for proper configuration. Missing required fields will cause errors.
affects: >=0.8.0
Errors
Common errors & fixes
Cannot find module 'graphql-codegen-generators'
Package name is misspelled or not installed; or using a newer version of the CLI that does not include it.
fix
Install the correct package: `npm install --save-dev graphql-codegen-generators@0.8.21` or migrate to @graphql-codegen/typescript.
TypeError: templates is not iterable
Incorrect import of generator templates. The 'types' variable is an object, not an array. The generate function expects a single generator config, not multiple.
fix
Pass a single generator config or use the built-in 'types' generator directly: `generate({ schema, templates: types })`.
Cannot read property 'index' of undefined
Using EInputType.SINGLE_FILE without providing an 'index' template in the config object.
fix
Ensure the config object has a 'templates' property with an 'index' key containing the compiled Handlebars template string.
UnhandledPromiseRejectionWarning: Error: No schema found
The schema argument passed to generate() is undefined or malformed.
fix
Provide a valid GraphQLSchema object from 'graphql' (e.g., buildSchema or buildClientSchema).
Upgrade
Version history
0.8.21latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency for GraphQL schema parsing
graphql-codegen-corerequiredCore library providing context types and compilation logic
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-codegen-generators — npm install graphql-codegen-generators · libregistry