GraphQL Architect
使用企业级模式设计可扩展的 GraphQL API
构建生产级 GraphQL 系统需要具备联邦、性能和安全方面的专业知识。本技能提供经过验证的可扩展模式设计和优化模式。
Die Skill-ZIP herunterladen
In Claude hochladen
Gehe zu Einstellungen → Fähigkeiten → Skills → Skill hochladen
Einschalten und loslegen
Teste es
Verwendung von "GraphQL Architect". Design a user profile schema with posts and comments
Erwartetes Ergebnis:
- type User {
- id: ID!
- username: String!
- email: String!
- profile: Profile
- posts: [Post!]!
- createdAt: DateTime!
- }
- type Profile {
- bio: String
- avatar: String
- location: String
- }
- type Post {
- id: ID!
- title: String!
- content: String!
- author: User!
- comments: [Comment!]!
- }
Verwendung von "GraphQL Architect". Optimize resolver fetching user posts
Erwartetes Ergebnis:
- Use DataLoader to batch and cache user post fetching:
- const postLoader = new DataLoader(async (userIds) => {
- const posts = await Post.findAll({
- where: { userId: userIds },
- include: [User]
- });
- return userIds.map(id => posts.filter(p => p.userId === id));
- });
- This reduces N queries to 1 batched query.
Sicherheitsaudit
SicherStatic analysis scanned 0 files with 0 lines and detected no suspicious patterns. This is a prompt-only skill containing instructional content for GraphQL architecture guidance. No executable code, network access, filesystem operations, or external command execution present.
Qualitätsbewertung
Was du bauen kannst
企业联邦架构
设计多团队联邦 GraphQL 架构,包含子图组合、模式治理和跨团队协作模式。
性能优化审计
分析现有 GraphQL 模式的 N+1 查询问题,实施 DataLoader 模式,并配置多级缓存策略。
安全加固实施
实施字段级授权、查询复杂度分析、速率限制和生产安全配置。
Probiere diese Prompts
为 [resource type] 设计一个具有 CRUD 操作的 GraphQL 模式。包含适当的标量类型、用于变更的输入类型,并遵循命名约定。解释类型之间的关系。
为 [domain] 规划 Apollo Federation v2 子图。识别实体、key 指令和外部类型引用。展示此子图如何与整体联邦架构集成。
审查此 GraphQL 模式和解析器实现的性能问题。识别 N+1 查询模式,建议 DataLoader 实现,并推荐字段级和查询级缓存策略。
审计此 GraphQL 服务器配置的安全漏洞。检查内省设置、CORS 配置、速率限制、查询深度限制和字段级授权。提供具体的修复步骤。
Bewährte Verfahren
- 设计模式时考虑版本控制和演进 - 删除前先弃用
- 为所有解析器获取实施 DataLoader 以防止 N+1 查询问题
- 在生产部署前配置查询复杂度分析和速率限制
Vermeiden
- 在 GraphQL 模式中直接暴露数据库模型而没有抽象层
- 返回无界限列表而不使用连接模式或分页
- 在解析器中实现业务逻辑而不是在专用服务层中