PluginBench
Skill
Review
Audit score 70

graphql-architect

jeffallan/claude-skills

Design scalable GraphQL schemas with Apollo Federation, resolvers, and real-time subscriptions.

What is graphql-architect?

GraphQL Architect helps you design and implement production-grade GraphQL APIs using schema-first design, Apollo Federation 2.5+, and performance optimization patterns. Use it when architecting new GraphQL services, extending federated graphs, building subscriptions, or optimizing resolver performance.

  • Design domain-driven GraphQL schemas with types, interfaces, unions, and federation directives
  • Implement efficient resolvers using DataLoader patterns to prevent N+1 query problems
  • Compose and validate multi-subgraph Apollo Federation architectures
  • Build real-time subscriptions with WebSocket and pub/sub patterns
  • Apply query complexity analysis and depth limiting for security
  • Migrate REST APIs to GraphQL with proper schema design

How to install graphql-architect

npx skills add https://github.com/jeffallan/claude-skills --skill graphql-architect
Prerequisites
  • Apollo Server installed
  • Basic understanding of GraphQL SDL and type system
  • Node.js environment for resolver implementation
Claude Code
Cursor
Windsurf
Cline

How to use graphql-architect

  1. 1.Map your business domains to GraphQL types and entities
  2. 2.Create schema definition (SDL) with proper nullable patterns and federation directives
  3. 3.Run schema composition validation to verify all @key directives and entity references
  4. 4.Implement resolvers with DataLoader for batching and caching
  5. 5.Add query complexity analysis rules to your Apollo Server configuration
  6. 6.Configure subscriptions with WebSocket and pub/sub if needed
  7. 7.Document all types and fields; provide example queries for operations

Use cases

Good for
  • Architecting a new federated GraphQL API across multiple services
  • Extending an existing Apollo Federation graph with new subgraphs and entities
  • Implementing real-time data updates via GraphQL subscriptions
  • Optimizing resolver performance by batching database queries with DataLoader
  • Adding query complexity limits and depth validation to prevent abuse
Who it's for
  • GraphQL architects designing new APIs
  • Backend engineers implementing resolvers and subscriptions
  • API platform teams managing federated graphs
  • DevOps/SRE engineers optimizing GraphQL performance
  • Teams migrating from REST to GraphQL

graphql-architect FAQ

When should I use Apollo Federation vs schema stitching?

Use Apollo Federation 2.5+ for production federated architectures. It provides better composition, entity resolution, and subgraph independence. Schema stitching is legacy; Federation is the modern standard.

How do I prevent N+1 query problems?

Use DataLoader to batch database queries. Create one DataLoader instance per request in context, and call loader.load() in resolvers instead of direct database queries. DataLoader automatically batches all loads from a single tick.

What query complexity limit should I set?

Start with 1000 complexity units and monitor real usage. Adjust based on your largest legitimate queries. Document the threshold and justification for any increases.

How do I handle real-time updates?

Use GraphQL subscriptions with WebSocket transport and a pub/sub system (Redis, RabbitMQ, or in-memory). Implement subscription resolvers that return async iterables and publish events when data changes.

Should I use @shareable for types across subgraphs?

Use @shareable only when a type is defined in multiple subgraphs and you want to extend it. For owned types, define them once with @key and reference via @external in other subgraphs.

Full instructions (SKILL.md)

Source of truth, from jeffallan/claude-skills.


name: graphql-architect description: Use when designing GraphQL schemas, implementing Apollo Federation, or building real-time subscriptions. Invoke for schema design, resolvers with DataLoader, query optimization, federation directives. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.0" domain: api-architecture triggers: GraphQL, Apollo Federation, GraphQL schema, API graph, GraphQL subscriptions, Apollo Server, schema design, GraphQL resolvers, DataLoader role: architect scope: design output-format: schema related-skills: api-designer, microservices-architect, database-optimizer

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
    • 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
  4. Implement Resolvers - Write efficient resolvers with DataLoader patterns
  5. Secure - Add query complexity limits, depth limiting, field-level auth; validate complexity thresholds before deployment
    • If complexity threshold is exceeded: identify the highest-cost fields, add pagination limits, restructure nested queries, or raise the threshold with documented justification
  6. Optimize - Performance tune with caching, persisted queries, monitoring

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Schema Designreferences/schema-design.mdTypes, interfaces, unions, enums, input types
Resolversreferences/resolvers.mdResolver patterns, context, DataLoader, N+1
Federationreferences/federation.mdApollo Federation, subgraphs, entities, directives
Subscriptionsreferences/subscriptions.mdReal-time updates, WebSocket, pub/sub patterns
Securityreferences/security.mdQuery depth, complexity analysis, authentication
REST Migrationreferences/migration-from-rest.mdMigrating 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