graphql-ts-generator
Automatically generates TypeScript types from GraphQL schema files with CLI integration for developers and AI agents.
- License 许可
- MIT
- 最近更新
- 2026-06-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- graphql-ts-generator
- description
- Automatically generates TypeScript types from GraphQL schema files with CLI integration for developers and AI agents.
03 SKILL.md 正文
GraphQL TypeScript Generator Skill
Product Plan
One-Sentence Description
Automatically generates TypeScript types from GraphQL schema files with CLI integration for developers and AI agents.
Core Capabilities
- Convert GraphQL schema (.graphql, .gql) files to TypeScript interfaces and types
- Generate client-side TypeScript types for GraphQL queries and mutations
- Provide command-line interface for direct file processing
- Handle complex GraphQL types including unions, interfaces, and enums
- Validate GraphQL schemas before TypeScript generation
- Integrate with OpenClaw agent workflows for automation
- Support batch processing of multiple schema files
Out of Scope
- GraphQL server implementation
- Database schema management
- Runtime GraphQL client code generation
- Documentation generation beyond type definitions
- Performance optimization for very large schemas
- Custom code formatting beyond TypeScript standards
- Integration with specific frameworks (React, Angular, etc.)
Trigger Scenarios
- "Generate TypeScript types from this GraphQL schema"
- "Create TypeScript interfaces from GraphQL schema file"
- "Convert .graphql file to TypeScript types"
- "Auto-generate types for my GraphQL API"
- "Generate client types from GraphQL schema"
- "Transform GraphQL schema to TypeScript"
Required Resources
- scripts/: Contains the main TypeScript generation logic and CLI entry point
- references/: GraphQL schema examples and test cases
- assets/: CLI help text, configuration templates, and documentation assets
Key Files
- scripts/index.ts: Main CLI entry point
- scripts/generator.ts: Core type generation logic
- scripts/cli.ts: Command-line interface implementation
- scripts/utils.ts: Utility functions for GraphQL parsing
- references/sample.graphql: Example GraphQL schema for testing
- references/test-schema.graphql: Complex test case with various GraphQL features
- assets/README.md: User documentation
- assets/package.json: Skill package configuration
- assets/tsconfig.json: TypeScript configuration for the skill
- assets/cli-help.txt: CLI help text and usage examples
Acceptance Criteria
- Skill correctly processes simple GraphQL schemas and generates valid TypeScript types
- Skill handles complex GraphQL features (unions, interfaces, enums)
- CLI interface accepts schema file paths and outputs TypeScript files
- Error handling for invalid GraphQL schemas
- Integration with OpenClaw agent workflows for automated processing
- Documentation includes usage examples and troubleshooting
- Test cases pass for all sample GraphQL schemas
- Generated TypeScript types are immediately usable in TypeScript projects
Architecture Overview
Directory Layout
├── scripts/
│ ├── index.ts # CLI entry point
│ ├── generator.ts # Type generation logic (Unions, Interfaces, Enums)
│ ├── cli.ts # Command-line argument parsing
│ └── utils.ts # GraphQL parsing utilities
├── references/
│ ├── sample.graphql # Basic schema example
│ └── test-schema.graphql # Complex test cases
├── assets/
│ ├── README.md # User documentation
│ ├── package.json # Skill package metadata
│ ├── tsconfig.json # TypeScript config
│ └── cli-help.txt # CLI usage examples
Scripts Design
scripts/index.ts
- Language: TypeScript
- Inputs:
argv(script arguments via CLI) - Outputs: Generates TypeScript files in output directory
- Core Logic: Parses CLI args → Loads schema → Calls
generator.ts→ Writes output
scripts/generator.ts
- Language: TypeScript
- Inputs: GraphQL schema AST (parsed from file)
- Outputs: TypeScript interfaces, types
- Core Logic: Type transformation rules for:
- Scalar types → TS primitives
- Object types → TS interfaces
- Union types → Discriminated unions
- Enum types → TS enum
scripts/cli.ts
- Language: TypeScript
- Inputs: Raw command-line arguments
- Outputs: Processed schema file paths
- Core Logic: Argument validation → Schema file reading → Result routing
scripts/utils.ts
- Language: TypeScript
- Inputs: Raw GraphQL text
- Outputs: Parsed AST
- Core Logic: GraphQL parser implementation with error handling
References Design
references/sample.graphql
- Content: Basic schema with Query/Mutation
- Usage: Demonstration for new users
references/test-schema.graphql
- Content: Features unions, interfaces, nested enums
- Usage: Testing boundary cases during development
Data Flow
- CLI receives schema path via arguments
cli.tsvalidates and loads schema fileutils.tsparses schema to ASTgenerator.tsprocesses AST using transformation rules- Outputs TypeScript files to
dist/directory
Integration Points
Agent Workflow Example:
- User requests: "Generate types from schema at /docs/api.graphql"
- Agent triggers CLI via
exec "graphql-ts-generator /docs/api.graphql" - CLI processes schema, calls generator logic
- Generated .ts files returned to agent as attachment
- Agent presents files to user in chat interface
CLI Automation:
- Agent can schedule batch processing
- "Generate types for all .graphql in /schemas/" →
exec "graphql-ts-generator /schemas/*.graphql"
Usage Instructions
Installation
npm install -g graphql-ts-generator
Basic Usage
# Generate types from a single schema file
graphql-ts-generator schema.graphql
# Generate types and specify output directory
graphql-ts-generator schema.graphql --output dist/
# Process multiple schema files
graphql-ts-generator "schemas/*.graphql"
Options
-o, --output <dir>: Output directory for generated TypeScript files (default:./generated)-f, --format <style>: Code formatting style (default: standard)-v, --verbose: Enable verbose logging--no-validate: Skip schema validation (not recommended)-h, --help: Show help message
Output
The generator produces TypeScript files containing:
- Interfaces for GraphQL object types
- Type aliases for GraphQL unions
- Enums for GraphQL enums
- Proper nullability handling (TypeScript
| null)
Integration with OpenClaw
This skill integrates seamlessly with OpenClaw agent workflows. Trigger via:
- Direct CLI execution in agent sessions
- Scheduled batch generation jobs
- Automated pipeline processing
See assets/README.md for complete documentation.
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
ceaser
Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir/UltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).
ceaser-send
Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir/UltraHonk zero-knowledge proofs.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
moldium
Post and manage content on the Moldium blog platform. Triggered by "post to Moldium", "write a blog post", "publish an article", etc.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http://weakaccept.top:8000/.