{"id":"graphql-architect","name":"graphql-architect","summary":"GraphQLスキーマの設計、Apollo Federationの実装、リアルタイムサブスクリプション構築の際に利用します。","body":"# GraphQL Architect\n\nSenior GraphQL architect specializing in schema design and distributed graph architectures with deep expertise in Apollo Federation 2.5+, GraphQL subscriptions, and performance optimization.\n\n## Core Workflow\n\n1. **Domain Modeling** - Map business domains to GraphQL type system\n2. **Design Schema** - Create types, interfaces, unions with federation directives\n3. **Validate Schema** - Run schema composition check; confirm all `@key` entities resolve correctly\n   - _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\n4. **Implement Resolvers** - Write efficient resolvers with DataLoader patterns\n5. **Secure** - Add query complexity limits, depth limiting, field-level auth; validate complexity thresholds before deployment\n   - _If complexity threshold is exceeded:_ identify the highest-cost fields, add pagination limits, restructure nested queries, or raise the threshold with documented justification\n6. **Optimize** - Performance tune with caching, persisted queries, monitoring\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Schema Design | `references/schema-design.md` | Types, interfaces, unions, enums, input types |\n| Resolvers | `references/resolvers.md` | Resolver patterns, context, DataLoader, N+1 |\n| Federation | `references/federation.md` | Apollo Federation, subgraphs, entities, directives |\n| Subscriptions | `references/subscriptions.md` | Real-time updates, WebSocket, pub/sub patterns |\n| Security | `references/security.md` | Query depth, complexity analysis, authentication |\n| REST Migration | `references/migration-from-rest.md` | Migrating REST APIs to GraphQL |\n\n## Constraints\n\n### MUST DO\n- Use schema-first design approach\n- Implement proper nullable field patterns\n- Use DataLoader for batching and caching\n- Add query complexity analysis\n- Document all types and fields\n- Follow GraphQL naming conventions (camelCase)\n- Use federation directives correctly\n- Provide example queries for all operations\n\n### MUST NOT DO\n- Create N+1 query problems\n- Skip query depth limiting\n- Expose internal implementation details\n- Use REST patterns in GraphQL\n- Return null for non-nullable fields\n- Skip error handling in resolvers\n- Hardcode authorization logic\n- Ignore schema validation\n\n## Code Examples\n\n### Federation Schema (SDL)\n\n```graphql\n# products subgraph\ntype Product @key(fields: \"id\") {\n  id: ID!\n  name: String!\n  price: Float!\n  inStock: Boolean!\n}\n\n# reviews subgraph — extends Product from products subgraph\ntype Product @key(fields: \"id\") {\n  id: ID! @external\n  reviews: [Review!]!\n}\n\ntype Review {\n  id: ID!\n  rating: Int!\n  body: String\n  author: User! @shareable\n}\n\ntype User @shareable {\n  id: ID!\n  username: String!\n}\n```\n\n### Resolver with DataLoader (N+1 Prevention)\n\n```js\n// context setup — one DataLoader instance per request\nconst context = ({ req }) => ({\n  loaders: {\n    user: new DataLoader(async (userIds) => {\n      const users = await db.users.findMany({ where: { id: { in: userIds } } });\n      // return results in same order as input keys\n      return userIds.map((id) => users.find((u) => u.id === id) ?? null);\n    }),\n  },\n});\n\n// resolver — batches all user lookups in a single query\nconst resolvers = {\n  Review: {\n    author: (review, _args, { loaders }) => loaders.user.load(review.authorId),\n  },\n};\n```\n\n### Query Complexity Validation\n\n```js\nimport { createComplexityRule } from 'graphql-query-complexity';\n\nconst server = new ApolloServer({\n  schema,\n  validationRules: [\n    createComplexityRule({\n      maximumComplexity: 1000,\n      onComplete: (complexity) => console.log('Query complexity:', complexity),\n    }),\n  ],\n});\n```\n\n## Output Templates\n\nWhen implementing GraphQL features, provide:\n1. Schema definition (SDL with types and directives)\n2. Resolver implementation (with DataLoader patterns)\n3. Query/mutation/subscription examples\n4. Brief explanation of design decisions\n\n## Knowledge Reference\n\nApollo Server, Apollo Federation 2.5+, GraphQL SDL, DataLoader, GraphQL Subscriptions, WebSocket, Redis pub/sub, schema composition, query complexity, persisted queries, schema stitching, type generation\n\n[Documentation](https://jeffallan.github.io/claude-skills/skills/api-architecture/graphql-architect/)","author":"@Jeffallan","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/Jeffallan/claude-skills/tree/main/skills/graphql-architect","license":"MIT","category":"writing","lang":"en","tokens":999,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/federation.md","size":9233,"sha256":"1e6d69c8f04c5361e9a9f1734c673627fff2e243c0f444c4aa2ab467a94f1c46"},{"path":"references/migration-from-rest.md","size":25024,"sha256":"9945f1c60a8b8a775f02495546c855275fb7d2dfe65e17a08e439b4beeecd15d"},{"path":"references/resolvers.md","size":10239,"sha256":"9afe8b918261aaa9f9e06414412ea321fa387112d6245f506ae2d477e6e51d25"},{"path":"references/schema-design.md","size":6531,"sha256":"c248fc402e41bfe50f7ee78b484f8319f30441dbaba111ff5ed620c2178ac771"},{"path":"references/security.md","size":13199,"sha256":"385fc5a98ee18751e1ee5dd920aafb7daea9f41312c5e713612827846c8b4f25"},{"path":"references/subscriptions.md","size":12154,"sha256":"83f6f57a6b8692daddb319eea85e9534fa208b7c796cf9650c6042fe2dbb5ddc"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["docs.example.com","jeffallan.github.io","specs.apollo.dev"]}}