graphql-api-design
БесплатноЗапускает вложенные скриптыНе проверенComprehensive GraphQL API design with Apollo Server, GraphQL Yoga, and Federation v2
Об этом скилле
GraphQL API Design Skill
Level 1: Quick Reference (~800 tokens)
GraphQL vs REST: When to Use GraphQL
Use GraphQL When:
- Clients need flexible data fetching (avoid over/under-fetching)
- Multiple client types with different data requirements (mobile, web, IoT)
- Real-time data updates via subscriptions
- Complex data relationships and nested queries
- Rapid frontend iteration without backend changes
Use REST When:
- Simple CRUD operations with predictable access patterns
- File uploads/downloads (though GraphQL can handle with multipart)
- HTTP caching is critical (GET requests)
- Team unfamiliarity with GraphQL tooling
Schema Design Principles
Core Concepts:
- Type System: Strongly typed schema defines API contract
- Query: Read operations (like GET)
- Mutation: Write operations (like POST/PUT/DELETE)
- Subscription: Real-time data streams over WebSocket
- Resolver: Function that returns data for a field
Design Rules:
- Use nouns for types, verbs for mutations
- Prefer pagination over large lists
- Design for client use cases, not database structure
- Use interfaces for polymorphic types
- Leverage custom scalars (DateTime, Email, URL)
Essential Checklist
Schema Design
- Define clear type hierarchy (Query, Mutation, Subscription roots)
- Use descriptive field names and types
- Add field-level descriptions for documentation
- Implement input validation with custom scalars
- Design pagination with cursor-based approach
Resolvers & Performance
- Implement DataLoader for N+1 query prevention
- Batch database queries within request context
- Add resolver-level caching strategy
- Use field-level resolvers only when needed
- Implement query complexity analysis
Authorization & Security
- Context-based authentication (verify tokens)
- Field-level authorization with directives
- Query depth limiting (prevent deeply nested attacks)
- Query complexity cost analysis
- Rate limiting per client/operation
Federation (Microservices)
- Define subgraph schemas with
@keydirectives - Implement reference resolvers for entity resolution
- Configure Apollo Gateway for schema composition
- Set up schema registry for version control
- Monitor federated trace data
Error Handling
- Return structured errors with codes and extensions
- Distinguish user errors from system errors
- Implement partial error responses
- Log errors with correlation IDs
- Mask sensitive data in error messages
Testing
- Unit test resolvers with mocked data sources
- Integration test with test database
- Schema validation with apollo CLI
- Performance test with realistic queries
- Security test for common vulnerabilities
Quick Wins
Immediate Optimizations:
DataLoader: Reduce N+1 queries by 90%+
const userLoader = new DataLoader(async (userIds) => { const users = await db.users.findMany({ where: { id: { in: userIds } } }); return userIds.map(id => users.find(u => u.id === id)); });Query Complexity: Prevent expensive queries
const server = new ApolloServer({ schema, plugins: [createComplexityPlugin({ maximumComplexity: 1000 })] });Response Caching: Cache at resolver or HTTP level
@cacheControl(maxAge: 3600) type User { id: ID! name: String! }Subscription Filtering: Reduce unnecessary events
subscribe: { messageAdded: { subscribe: withFilter( () => pubsub.asyncIterator('MESSAGE_ADDED'), (payload, variables) => payload.channelId === variables.channelId ) } }
Level 2:
📚 Full Examples: See REFERENCE.md for complete code samples, detailed configurations, and production-ready implementations.
Implementation Guide (~4500 tokens)
1. GraphQL Schema Design Best Practices
Type System Fundamentals
Object Types: Primary building blocks
See REFERENCE.md for complete implementation.
Input Types: For mutations and complex arguments
See REFERENCE.md for complete implementation.
Enums: For fixed sets of values
See REFERENCE.md for complete implementation.
Interfaces: For polymorphic types
See REFERENCE.md for complete implementation.
Unions: For heterogeneous result types
union SearchResult = User | Post | Comment
type Query {
search(query: String!): [SearchResult!]!
}
Custom Scalars: For domain-specific types
scalar DateTime
scalar Email
scalar URL
scalar JSON
scalar PositiveInt
Query Design Patterns
Root Query Type
*See REFERENCE.md for com
Установить graphql-api-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл graphql-api-design?
Comprehensive GraphQL API design with Apollo Server, GraphQL Yoga, and Federation v2
Как установить скилл graphql-api-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл graphql-api-design запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic