GraphQL 转 TypeScript
将 GraphQL 模式转换为 TypeScript 类型。支持类型、输入、枚举和标量。
Supported GraphQL constructs:
- •
type→ interface/type - •
input→ interface/type with optional fields - •
enum→ TypeScript enum - •
scalar→ type alias - • Lists
[Type]→ Type[] - • Non-null
!modifier
Type-Safe GraphQL - 技术详情
Generating TypeScript types from GraphQL schemas ensures type safety across your client and server. The GraphQL type system maps naturally to TypeScript, with nullable fields becoming optional properties.
命令行替代方案
// GraphQL\ntype User {\n id: ID!\n name: String\n}\n\n// TypeScript\ninterface User {\n id: string;\n name: Maybe<string>;\n}