@soda-gql/codegen
v0.3.0
Published
GraphQL schema code generation for soda-gql
Maintainers
Readme
@soda-gql/codegen
Multi-schema GraphQL code generation engine for soda-gql.
Installation
bun add -D @soda-gql/codegenNote: This package is typically used indirectly via @soda-gql/cli. Direct usage is only needed for advanced integration scenarios.
Overview
This package provides the code generation engine that transforms GraphQL schemas into type-safe TypeScript modules. It supports:
- Multiple schema configurations
- Custom scalar definitions
- Runtime adapter integration
- Incremental generation
Programmatic Usage
For advanced use cases where you need to integrate code generation into your own build pipeline:
import { runCodegen } from "@soda-gql/codegen";
const result = await runCodegen({
outPath: "./src/graphql-system/index.ts",
format: "json",
schemas: {
default: {
schema: "./schema.graphql",
inject: {
scalars: "./scalars.ts",
},
},
},
});
if (result.isErr()) {
console.error("Code generation failed:", result.error);
} else {
console.log("Code generation successful");
}Features
- Multi-Schema Support: Generate modules for multiple GraphQL schemas in a single run
- Type Safety: Full TypeScript type generation from GraphQL schema
- Custom Scalars: Support for custom scalar type definitions
- Error Handling: Type-safe error handling using neverthrow
Related Packages
- @soda-gql/cli - Command-line interface (recommended for most users)
- @soda-gql/config - Configuration management
- @soda-gql/core - Core types and utilities
License
MIT
