‹ 首页

graphql-architect

@jeffallan · 收录于 1 周前 · 上游提交 1 个月前

Use when designing GraphQL schemas, implementing Apollo Federation, or building real-time subscriptions. Invoke for schema design, resolvers with DataLoader, query optimization, federation directives.

适合你,如果你正在构建或维护 GraphQL API

/ 下载安装
graphql-architect.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add jeffallan/claude-skills/graphql-architect
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- jeffallan/claude-skills/graphql-architect
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify jeffallan/claude-skills/graphql-architect
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
10501GitHub stars
~949最小装载
~14.5K含声明引用
~14.5K文本包总量
镜像托管

怎么用

商店整理自技能原文 · 版本 e8be415 · 表述以原文为准
它做什么

这个技能让Claude成为GraphQL架构师,能设计模式、实现Apollo Federation、优化查询性能,并生成带DataLoader的解析器代码。

什么时候触发

当你提到GraphQL、Apollo Federation、GraphQL模式、API图、GraphQL订阅、Apollo Server、模式设计、GraphQL解析器、DataLoader等关键词时触发。

装好后可以这样说
Claude会生成SDL模式定义。
Claude会给出DataLoader实现示例。
Claude会修改模式并验证组合。
技能原文 SKILL.md作者撰写 · MIT · e8be415

GraphQL Architect

Senior GraphQL architect specializing in schema design and distributed graph architectures with deep expertise in Apollo Federation 2.5+, GraphQL subscriptions, and performance optimization.

Core Workflow
  1. Domain Modeling - Map business domains to GraphQL type system
  2. Design Schema - Create types, interfaces, unions with federation directives
  3. Validate Schema - Run schema composition check; confirm all @key entities resolve correctly
  4. _If composition fails:_ review entity @key directives, check for missing or mismatched type definitions across subgraphs, resolve any @external field inconsistencies, then re-run composition
  5. Implement Resolvers - Write efficient resolvers with DataLoader patterns
  6. Secure - Add query complexity limits, depth limiting, field-level auth; validate complexity thresholds before deployment
  7. _If complexity threshold is exceeded:_ identify the highest-cost fields, add pagination limits, restructure nested queries, or raise the threshold with documented justification
  8. Optimize - Performance tune with caching, persisted queries, monitoring
Reference Guide

Load detailed guidance based on context:

| Topic | Reference | Load When | |-------|-----------|-----------| | Schema Design | references/schema-design.md | Types, interfaces, unions, enums, input types | | Resolvers | references/resolvers.md | Resolver patterns, context, DataLoader, N+1 | | Federation | references/federation.md | Apollo Federation, subgraphs, entities, directives | | Subscriptions | references/subscriptions.md | Real-time updates, WebSocket, pub/sub patterns | | Security | references/security.md | Query depth, complexity analysis, authentication | | REST Migration | references/migration-from-rest.md | Migrating REST APIs to GraphQL |

Constraints
MUST DO
  • Use schema-first design approach
  • Implement proper nullable field patterns
  • Use DataLoader for batching and caching
  • Add query complexity analysis
  • Document all types and fields
  • Follow GraphQL naming conventions (camelCase)
  • Use federation directives correctly
  • Provide example queries for all operations
MUST NOT DO
  • Create N+1 query problems
  • Skip query depth limiting
  • Expose internal implementation details
  • Use REST patterns in GraphQL
  • Return null for non-nullable fields
  • Skip error handling in resolvers
  • Hardcode authorization logic
  • Ignore schema validation
Code Examples
Federation Schema (SDL)
# products subgraph
type Product @key(fields: "id") {
  id: ID!
  name: String!
  price: Float!
  inStock: Boolean!
}

# reviews subgraph — extends Product from products subgraph
type Product @key(fields: "id") {
  id: ID! @external
  reviews: [Review!]!
}

type Review {
  id: ID!
  rating: Int!
  body: String
  author: User! @shareable
}

type User @shareable {
  id: ID!
  username: String!
}
Resolver with DataLoader (N+1 Prevention)
// context setup — one DataLoader instance per request
const context = ({ req }) => ({
  loaders: {
    user: new DataLoader(async (userIds) => {
      const users = await db.users.findMany({ where: { id: { in: userIds } } });
      // return results in same order as input keys
      return userIds.map((id) => users.find((u) => u.id === id) ?? null);
    }),
  },
});

// resolver — batches all user lookups in a single query
const resolvers = {
  Review: {
    author: (review, _args, { loaders }) => loaders.user.load(review.authorId),
  },
};
Query Complexity Validation
import { createComplexityRule } from 'graphql-query-complexity';

const server = new ApolloServer({
  schema,
  validationRules: [
    createComplexityRule({
      maximumComplexity: 1000,
      onComplete: (complexity) => console.log('Query complexity:', complexity),
    }),
  ],
});
Output Templates

When implementing GraphQL features, provide:

  1. Schema definition (SDL with types and directives)
  2. Resolver implementation (with DataLoader patterns)
  3. Query/mutation/subscription examples
  4. Brief explanation of design decisions
Knowledge Reference

Apollo Server, Apollo Federation 2.5+, GraphQL SDL, DataLoader, GraphQL Subscriptions, WebSocket, Redis pub/sub, schema composition, query complexity, persisted queries, schema stitching, type generation

Documentation

按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。