بنقرة واحدة
graphql-api-design
Comprehensive GraphQL API design with Apollo Server, GraphQL Yoga, and Federation v2
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Comprehensive GraphQL API design with Apollo Server, GraphQL Yoga, and Federation v2
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Orchestration & Events:
Kubernetes standards for container orchestration, deployments, services, ingress, ConfigMaps, Secrets, and security policies. Covers production-ready configurations, monitoring, and best practices for cloud-native applications.
Master Kotlin coding standards with null safety, coroutines, and idiomatic patterns. Use when developing JVM/Android applications requiring type-safe async programming.
Comprehensive coding standards and best practices for maintainable, consistent software development across multiple languages and paradigms
React frontend standards covering hooks (useState, useEffect, useContext, custom hooks), state management (Context API, Redux, Zustand), performance optimization (memoization, lazy loading, code splitting), testing with React Testing Library, and accessibility (WCAG 2.1, ARIA) for modern SPAs
Security Operations Center (SOC) practices, incident response, SIEM management, and threat hunting following NIST 800-61
استنادا إلى تصنيف SOC المهني
| name | graphql-api-design |
| category | api |
| difficulty | intermediate |
| estimated_time | 45 minutes |
| description | Comprehensive GraphQL API design with Apollo Server, GraphQL Yoga, and Federation v2 |
| version | 1.0.0 |
Use GraphQL When:
Use REST When:
Core Concepts:
Design Rules:
@key directivesImmediate 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
)
}
}
📚 Full Examples: See REFERENCE.md for complete code samples, detailed configurations, and production-ready implementations.
Implementation Guide (~4500 tokens)
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
Root Query Type
See REFERENCE.md for complete implementation.
Cursor-Based Pagination (Relay spec)
See REFERENCE.md for complete implementation.
Input/Payload Pattern: Consistent structure
See REFERENCE.md for complete implementation.
Optimistic Response Support
type UpdatePostPayload {
post: Post
clientMutationId: String # Client-provided ID for tracking
errors: [ValidationError!]
}
Real-Time Events
See REFERENCE.md for complete implementation.
Basic Resolvers
See REFERENCE.md for complete implementation.
Resolver Best Practices
Solving the N+1 Problem
Without DataLoader (N+1 queries):
// For 10 posts, this executes 11 queries!
query {
posts { # 1 query
id
title
author { # 10 queries (one per post)
name
}
}
}
With DataLoader (2 queries):
See REFERENCE.md for complete implementation.
DataLoader in Context
See REFERENCE.md for complete implementation.
Using DataLoader in Resolvers
See REFERENCE.md for complete implementation.
Advanced DataLoader Patterns
See REFERENCE.md for complete implementation.
Users Subgraph
See REFERENCE.md for complete implementation.
Posts Subgraph
See REFERENCE.md for complete implementation.
Reference Resolvers
See REFERENCE.md for complete implementation.
Apollo Gateway Setup
See REFERENCE.md for complete implementation.
Managed Federation (Apollo Studio)
See REFERENCE.md for complete implementation.
JWT Token Verification
See REFERENCE.md for complete implementation.
Resolver-Level Authorization
See REFERENCE.md for complete implementation.
Schema Directives
See REFERENCE.md for complete implementation.
Directive Implementation
See REFERENCE.md for complete implementation.
Apollo Server Subscriptions
See REFERENCE.md for complete implementation.
PubSub Implementation
See REFERENCE.md for complete implementation.
Subscription Resolvers
See REFERENCE.md for complete implementation.
Apollo Cache Control
type Query {
user(id: ID!): User @cacheControl(maxAge: 3600)
posts: [Post!]! @cacheControl(maxAge: 300)
}
See REFERENCE.md for complete implementation.
Redis Response Caching
See REFERENCE.md for complete implementation.
Cost-Based Limiting
See REFERENCE.md for complete implementation.
Cursor-Based Pagination
See REFERENCE.md for complete implementation.
Custom Error Classes
See REFERENCE.md for complete implementation.
Error Formatting
See REFERENCE.md for complete implementation.
Resolver Tests
See REFERENCE.md for complete implementation.
GraphQL Server Tests
See REFERENCE.md for complete implementation.
Readiness and Liveness
See REFERENCE.md for complete implementation.
Apollo Studio Integration
See REFERENCE.md for complete implementation.
Custom Metrics
See REFERENCE.md for complete implementation.
See REFERENCE.md for complete implementation.
// TODO: Add advanced example for graphql
// This example shows production-ready patterns
// TODO: Add integration example showing how graphql
// works with other systems and services
See examples/graphql/ for complete working examples.
This skill integrates with:
Problem: Not testing edge cases and error conditions leads to production bugs
Solution: Implement comprehensive test coverage including:
Prevention: Enforce minimum code coverage (80%+) in CI/CD pipeline
Problem: Hardcoding values makes applications inflexible and environment-dependent
Solution: Use environment variables and configuration management:
Prevention: Use tools like dotenv, config validators, and secret scanners
Problem: Security vulnerabilities from not following established security patterns
Solution: Follow security guidelines:
Prevention: Use security linters, SAST tools, and regular dependency updates
Best Practices:
See templates/ and config/ directories for production-ready implementations:
graphql-schema.graphql - Complete schema exampleresolver-patterns.ts - Resolver implementation patternsfederation-config.yaml - Apollo Federation setupdataloader-implementation.ts - DataLoader patternssubscription-server.ts - Real-time subscriptionsapollo-studio.yaml - Monitoring configuration