名称: graphql-schema-generator 描述: 从数据模型生成GraphQL模式,包含解析器存根和联邦支持 允许使用的工具:
- Bash
- 读取
- 写入
- 全局匹配
GraphQL模式生成器技能
概述
从数据模型生成GraphQL SDL模式,具备类型推断、解析器存根生成、模式验证和Apollo联邦支持。
能力
- 从数据模型生成GraphQL SDL
- 从现有数据结构进行类型推断
- 解析器存根生成
- 模式验证和代码检查
- Apollo联邦支持
- 订阅类型生成
- 输入类型和变更生成
目标流程
- api-design-specification
输入模式
{
"type": "object",
"required": ["dataModels"],
"properties": {
"dataModels": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"fields": { "type": "array" },
"relationships": { "type": "array" }
}
}
},
"outputPath": {
"type": "string",
"description": "输出模式文件路径"
},
"options": {
"type": "object",
"properties": {
"generateResolvers": {
"type": "boolean",
"default": true
},
"federation": {
"type": "boolean",
"default": false
},
"generateSubscriptions": {
"type": "boolean",
"default": false
},
"generateInputTypes": {
"type": "boolean",
"default": true
}
}
}
}
}
输出模式
{
"type": "object",
"properties": {
"schemaPath": {
"type": "string"
},
"resolversPath": {
"type": "string"
},
"types": {
"type": "array",
"items": { "type": "string" }
},
"queries": {
"type": "array"
},
"mutations": {
"type": "array"
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'graphql-schema-generator',
context: {
dataModels: [
{ name: 'User', fields: ['id', 'name', 'email'] },
{ name: 'Post', fields: ['id', 'title', 'authorId'] }
],
outputPath: 'graphql/schema.graphql',
options: {
generateResolvers: true,
federation: false
}
}
}
}