implement-graphql-api — Claude Code command: GraphQL API
A slash command that builds a GraphQL API: schema, resolvers, subscriptions and N+1 protection. Useful when you need a real backend, not a sketch.
npx claude-code-templates@latest --command setup/implement-graphql-apiWhat implement-graphql-api does
The command scans your project first: framework from package.json or requirements.txt, existing schema and resolver files, database config, any auth traces. Then it builds the API around the approach you pick — schema-first, code-first or federation.
Six steps sit inside: type definitions, queries, mutations and custom scalars; resolvers with authorization and error handling; DataLoader batching; WebSocket subscriptions; query depth and complexity limits; developer tooling such as introspection and schema stitching. File uploads, directives and Apollo Federation are covered too.
You pass the approach as an argument: --schema-first, --code-first or --federation. Run it bare and the command has no idea which architecture to lay down, so decide that first. It holds Read, Write, Edit and Bash, meaning it can rewrite files and install packages. If your project already has a schema, check whether it gets replaced.
What it helps with
- define a GraphQL schema with types, queries and mutations
- write resolvers that check authorization
- kill N+1 queries with DataLoader batching
- add WebSocket subscriptions for live data
- cap query depth and complexity
Example prompts for the agent
- /implement-graphql-api --code-first
- /implement-graphql-api --schema-first
- /implement-graphql-api --federation
How to install implement-graphql-api
1claude-code-templates
npx claude-code-templates@latest --command setup/implement-graphql-api2Manually: put the files in place
.claude/commands/implement-graphql-api.mdCall it with /implement-graphql-api. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/implement-graphql-api.mdCall it with /prompts:implement-graphql-api. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/implement-graphql-api.prompt.mdManually: put the files in place
.gemini/commands/implement-graphql-api.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about implement-graphql-api
How do I install implement-graphql-api in Claude?
Run npx claude-code-templates@latest --command setup/implement-graphql-api. The command file then lives at .claude/commands/implement-graphql-api.md.
What does implement-graphql-api do?
It builds a GraphQL API end to end: schema, resolvers, DataLoader batching, subscriptions and query limits. You choose the schema approach with an argument.
Which schema approaches are supported?
Three: --schema-first, --code-first and --federation. Pick one before running, otherwise the command cannot tell which architecture to build.
Source text
implement-graphql-api.md · MIT
--- allowed-tools: Read, Write, Edit, Bash argument-hint: "[schema-approach] | --schema-first | --code-first | --federation" description: Implement GraphQL API with comprehensive schema, resolvers, and real-time subscriptions --- # Implement GraphQL API Implement comprehensive GraphQL API with modern best practices: **$ARGUMENTS** ## Current Application Context - Framework: @package.json or @requirements.txt (detect Apollo, GraphQL Yoga, etc.) - Existing API: !`find . -name "*.graphql" -o -name "*schema*" -o -name "*resolver*" | wc -l` - Database integration: @prisma/schema.prisma or database connection configs - Authentication: !`grep -r "auth\|jwt\|context" src/ 2>/dev/null | wc -l` ## Task Build production-ready GraphQL API with comprehensive functionality and performance optimization: **Schema Approach**: Use $ARGUMENTS to specify schema-first, code-first, or federation architecture **GraphQL Implementation**: 1. **Schema Design** - Type definitions, queries, mutations, subscriptions, custom scalars 2. **Resolver Architecture** - Data fetching, authentication, authorization, error handling 3. **DataLoader Integration** - N+1 query prevention, batch loading, caching strategies 4. **Real-time Features** - WebSocket subscriptions, live data updates, connection management 5. **Security & Performance** - Query complexity analysis, depth limiting, rate limiting 6. **Development Tools** - GraphQL Playground, introspection, schema stitching **Advanced Features**: File uploads, federated schemas, Apollo Federation, schema directives, and monitoring. **Production Readiness**: Implement comprehensive error handling, logging, metrics, and deployment strategies. **Output**: Complete GraphQL API with optimized resolvers, real-time capabilities, security controls, and developer documentation.
© davila7 · MIT · davila7/claude-code-templates