Registry / devops / graphql-typescript-deluxe

graphql-typescript-deluxe

JSON →
library0.1.0jsnpmunverified

Fast, experimental GraphQL TypeScript code generator that generates TypeScript code for GraphQL operations and fragments. Version 0.1.0, actively developed but still in beta. Key differentiators: claims to be at least 100x faster than graphql-codegen, generates readable types, supports stateful incremental generation (only rebuilds changed types), can output single .ts or separate .js/.d.ts files, adds TypeDoc comments. Caveats: experimental, may have bugs. Depends on graphql and @graphql-tools/load.

npm install graphql-typescript-deluxe
INSTALL
IMPORT
SIG · GRAPHQL-TYPESCRIPT
G
graphql-typescript-deluxe
devopsjavascriptv0.1.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.

Generator
import { Generator } from 'graphql-typescript-deluxe'
const Generator = require('graphql-typescript-deluxe');
Default export is not available; must use named import. The package appears to be ESM-first.
type Generator
import type { Generator } from 'graphql-typescript-deluxe'
import { Generator } from 'graphql-typescript-deluxe' (when only type is needed)
TypeScript users can import the type for type annotations without runtime import.
Generator class constructor
const generator = new Generator(schema)
const generator = new Generator()
A schema object (GraphQLSchema) is required; passing no argument throws an error.

Constructs a Generator with a GraphQL schema, adds a query document, builds the output, and prints the generated TypeScript code string.

import { Generator } from 'graphql-typescript-deluxe'; import { buildSchema } from 'graphql'; const schema = buildSchema(` type Query { hello: String! } `); const generator = new Generator(schema); generator.add({ documentNode: { kind: 'Document', definitions: [{ kind: 'OperationDefinition', operation: 'query', name: { value: 'myQuery' }, selectionSet: { kind: 'SelectionSet', selections: [{ kind: 'Field', name: { value: 'hello' } }] } }] }, filePath: 'query.graphql', }); const output = generator.build(); console.log(output.getOperations().getSource());
Debug
Known issues
breakingConstructor requires a schema parameter; passing undefined throws
fix
Always pass a valid GraphQLSchema object to new Generator(schema).
affects: >=0.1.0
deprecatedStatic method generateOnce is available but may be removed in future versions
fix
Use the stateful Generator class and call .build() instead.
affects: >=0.1.0
gotchaThe add() method expects documentNode to be a parsed DocumentNode, not a string
fix
Use parse() from the graphql package before calling generator.add().
affects: >=0.1.0
gotchaThe filePath in add() is used as a unique identifier; duplicate filePaths may cause unexpected behavior
fix
Ensure each filePath is unique across documents.
affects: >=0.1.0
gotchaThe build() method returns a new object each time; do not cache the result
fix
Call generator.build() fresh when needed.
affects: >=0.1.0
gotchaGenerated types may have incomplete or incorrect type definitions for certain edge cases (beta software)
fix
Review generated types for correctness and report bugs to the project.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: generator.build is not a function
The generator is not properly initialized or the import is wrong
fix
Ensure you import Generator correctly: import { Generator } from 'graphql-typescript-deluxe' and instantiate with new Generator(schema).
Error: Expected a schema to be passed to the Generator
Constructor called without a GraphQLSchema argument
fix
Pass a valid schema: const generator = new Generator(schema)
Error: Invalid document node
documentNode passed to add() is not a valid DocumentNode
fix
Parse your GraphQL string first: import { parse } from 'graphql'; generator.add({ documentNode: parse(doc), filePath: 'file.graphql' })
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
graphqlrequiredRequired for parsing schema and documents
@graphql-tools/loadrequiredRequired for loading schema from GraphQL SDL strings
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-typescript-deluxe — npm install graphql-typescript-deluxe · libregistry