Design and Implement GraphQL APIs
GraphQL skill covering schema design, DataLoader N+1 prevention, federation, and eight documented security/performance sharp edges.
Why it matters
Build robust and efficient GraphQL APIs by mastering schema design, resolver implementation, and client integration. This asset ensures your API contract is clear and performant, preventing common pitfalls like N+1 queries.
Outcomes
What it gets done
Design type-safe GraphQL schemas with intentional nullability.
Implement resolvers and leverage DataLoader for N+1 query prevention.
Integrate with popular GraphQL clients like Apollo and urql.
Understand GraphQL federation for microservice architectures.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-graphql | bash Overview
GraphQL
A GraphQL skill covering schema design, DataLoader-based N+1 prevention, federation, and code generation, built around eight documented sharp edges with severity, symptoms, and fixes for performance and security failures. Use for designing or hardening a GraphQL schema and resolvers; skip it for simple CRUD or high-performance public APIs, where REST is the better fit.
What it does
Covers GraphQL schema design (intentional nullability, union-typed payloads for errors-as-data, Relay-style pagination), resolvers, DataLoader for N+1 prevention, federation for microservices, subscriptions, code generation, and client integration with Apollo Client or urql. The skill's core is a set of eight documented "Sharp Edges," each with a severity rating, a situation, symptoms, why it breaks, and a recommended fix: resolvers making separate database queries per item (fixed with DataLoader batching), deeply nested queries that can DoS a server (fixed with depth-limit and complexity-limit validation rules), introspection left enabled in production (exposes the full schema to attackers), authorization implemented only in schema directives rather than resolvers, authorization checked on queries but not on individual fields (leaking private data alongside public fields), non-null field failures nullifying entire parent objects, expensive queries treated the same as cheap ones, and subscriptions not cleaned up on disconnect. It also lists a set of validation checks (introspection in production, direct database calls inside resolvers, missing depth limiting, resolvers without try-catch, JSON/Any types bypassing type safety, mutations returning bare types instead of error-carrying payloads, and list fields without pagination arguments).
When to use - and when NOT to
Use it when designing or reviewing a GraphQL schema, writing resolvers, preventing N+1 database queries, setting up federation, or integrating an Apollo or urql client. Per the skill's own 2025 lesson, GraphQL isn't always the answer: for simple CRUD, REST is simpler, and for high-performance public APIs, REST with caching wins - use GraphQL specifically when the application has complex data relationships and diverse client needs.
Inputs and outputs
Input is existing schema or resolver code, or a description of a performance, authorization, or caching problem. Output is schema and resolver code following the documented patterns: non-null-aware type definitions, DataLoader batching functions that preserve input order, union-typed mutation payloads for expected failures, Apollo Client cache typePolicies, a codegen.ts configuration, and targeted fixes for each Sharp Edge such as depthLimit(10), createComplexityLimitRule, and field-level authorization checks.
Integrations
Names @apollo/server, graphql-yoga, and mercurius for the server; @apollo/client, urql, and graphql-request for the client; graphql-codegen and dataloader as core tooling; graphql-depth-limit and graphql-validation-complexity for query limiting; and graphql-subscriptions with graphql-ws for subscription cleanup. It delegates database optimization to a postgres-wizard skill, authentication to authentication-oauth, caching to caching-strategies, and WebSocket infrastructure to backend, and is designed to pair with backend, postgres-wizard, nextjs-app-router, and react-patterns.
Who it's for
Backend and full-stack engineers building or hardening a GraphQL API - schema authors, resolver implementers, and anyone integrating an Apollo or urql client who need concrete performance and security fixes rather than conceptual GraphQL theory.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.