graphql

$npx mdskill add TheBeardedBearSAS/claude-craft/graphql

API GraphQL moderne avec federation, DataLoader, optimisations.

SKILL.md

.github/skills/graphqlView on GitHub ↗
---
name: graphql
description: GraphQL API design, Apollo Federation, schema stitching, resolvers, N+1 query problem. Use when implementing GraphQL API, federation, or optimizing queries.
triggers:
  files: ["**/graphql/**", "**/*.graphql", "**/*.gql", "**/schema.gql"]
  keywords: ["graphql", "apollo", "federation", "schema stitching", "resolver", "dataloader", "n+1", "query", "mutation", "subscription"]
auto_suggest: true
---

# GraphQL — Apollo Federation, Schema Design

API GraphQL moderne avec federation, DataLoader, optimisations.

## GraphQL vs REST

**GraphQL** — 1 query sur-mesure, no versioning, introspection auto  
**REST** — Multiple endpoints, over-fetching, v1/v2/v3

## Apollo Federation

```graphql
# Users service
type User @key(fields: "id") { id: ID!, name: String! }

# Orders service
extend type User @key(fields: "id") {
  id: ID! @external
  orders: [Order!]!
}
```

Gateway compose automatiquement les services.

## N+1 Problem — DataLoader

```javascript
// ❌ N+1 queries
User: { orders: (u) => db.orders.findByUserId(u.id) }

// ✅ DataLoader batch
const loader = new DataLoader(async (ids) => {
  const orders = await db.orders.findByUserIds(ids);
  return ids.map(id => orders.filter(o => o.userId === id));
});
User: { orders: (u) => loader.load(u.id) }
```

## Patterns

### Pagination (Relay)

```graphql
type UserConnection {
  edges: [{ node: User!, cursor: String! }]!
  pageInfo: { hasNextPage: Boolean!, endCursor: String }!
}
```

### Error Handling

```graphql
type CreateUserPayload {
  user: User
  errors: [{ field: String, message: String! }]
}
```

## Optimizations

**DataLoader** — Batch + cache  
**Persisted Queries** — Hash lookup  
**Depth Limiting** — Anti-DoS  
**Cost Analysis** — Query budget

---

Voir `@api-designer` pour design

More from TheBeardedBearSAS/claude-craft

SkillDescription
adapter-developmentErstellen Sie eine Paperclip-Extension — ein Plugin via @paperclipai/plugin-sdk oder einen Built-in-Adapter unter packages/adapters. Verwenden Sie dies beim Hinzufügen von AI-Runtimes oder Feature-Plugins.
aggregatesRègle 05 : Aggregates et Aggregate Roots. Use when implementing DDD patterns.
api-gatewayAPI Gateway patterns (Kong, Traefik, AWS API Gateway) — rate limiting, auth, routing, versioning. Use when implementing API gateway, reverse proxy, or API management.
architecture-clean-dddArchitecture Clean + DDD + Hexagonal - Atoll Tourisme. Use when designing architecture or reviewing code structure.
architecture-paperclipPaperclip-Two-Layer-Architektur (Control-Plane + Adapter). Verwenden Sie dies beim Entwerfen oder Reviewen von Paperclip-Modul-/Adapter-Grenzen.
asyncArchitecture async-first avec messaging et queues (Symfony Messenger, Laravel Queue, Ecotone). Use when working with async processing, queues, workers, background jobs.
atomic-tasksPattern GSD (Get Shit Done) - découper en tâches atomiques avec contextes subagent frais pour combattre le context rot. Use when planning complex work or working past 50% context usage.
coding-standards-tsPaperclip-TypeScript-Coding-Standards — Strict-Modus, Kebab-Files, kein any, strukturierte Logs. Verwenden Sie dies beim Schreiben oder Reviewen von Paperclip-TS-Code.
cqrsCQRS - Command Query Responsibility Segregation. Use when implementing DDD patterns, separating read/write models, event sourcing, or building scalable architectures with heterogeneous performance requirements.
ddd-patternsPatterns DDD - Atoll Tourisme. Use when implementing DDD patterns.