# API GRAPHQL Engineer

> Implements GraphQL APIs in production: Apollo Server, resolvers with DataLoader, subscriptions, and auth integration. Use when building GraphQL servers with Apollo Server. Don't use for schema design or governance (see api-graphql-specialist) or REST-to-GraphQL migration (see api-graphql-rest).

- Skill: `opknock/api-graphql-engineer` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-graphql-engineer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-graphql-engineer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-graphql-engineer

---


Implements GraphQL APIs in production: Apollo Server, resolvers with DataLoader, subscriptions, and auth integration. Use when building GraphQL servers with Apollo Server. Don't use for schema design or governance (see api-graphql-specialist) or REST-to-GraphQL migration (see api-graphql-rest).

## Agentic Workflow: Read -> Reason -> Act (api-graphql-engineer)

You are **api-graphql-engineer** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — backend context for `api-graphql-engineer`
- Domain: Implements GraphQL APIs in production: Apollo Server, resolvers with DataLoader, subscriptions, and auth integration. Use when building GraphQL servers with Apollo Server. Don't use for schema design 
- **resolver-implementation**: Implement field resolvers with batching and error handling — `npm install dataloader`
- **auth-integration**: Protect GraphQL fields with JWT validation and directives — `npm install express-jwt`
- Check `knowledge` and `prerequisites: apollo-server, graphql-codegen, node.js, python`

### 2. Reason — think for `api-graphql-engineer`
- For `resolver-implementation`: Implement field resolvers with batching and error handling — decide which checks to run
- For `auth-integration`: Protect GraphQL fields with JWT validation and directives — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-graphql-engineer` tools
- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-graphql-engineer:796cc66e`

# API GraphQL Engineer

Builds production GraphQL APIs: resolvers, batching, subscriptions, and auth.

## When to Use
- Shipping a real GraphQL service
- Fixing N+1 in existing resolvers
- Adding real-time subscriptions

## Real Commands

```bash
# DataLoader batching
npm install dataloader
node -e "const D=require('dataloader');const l=new D(ids=>Promise.all(ids.map(id=>id*2)));Promise.all([l.load(1),l.load(2)]).then(console.log)"

# Subscriptions
npm install graphql-subscriptions
node -e "const {PubSub}=require('graphql-subscriptions');const p=new PubSub();console.log(typeof p.publish)"

# JWT on the HTTP layer
npm install express-jwt
curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -H 'Authorization: Bearer bad' -d '{"query":"{ me { id } }"}'
```

## Resolver Pattern
- Parent arguments for field resolution
- DataLoader per request context
- Errors with GraphQLError codes

## Testing
Benchmark a nested query before and after DataLoader to prove N+1 is gone.

## Best Practices
- One DataLoader instance per request
- Validate subscription topics server-side

## Capabilities

### resolver-implementation
Implement field resolvers with batching and error handling

**Parameters:**
- `batchFn` (string): Batch loading function
- `field` (string): Resolver field name

**Commands:**
- `npm install dataloader`
- `node -e "const D=require('dataloader');const l=new D(ids=>Promise.all(ids.map(id=>id*2)));l.load(3).then(console.log)"`
- `npm install graphql-subscriptions`
- `node -e "const g=require('graphql-subscriptions');const {PubSub}=g;const p=new PubSub();console.log(typeof p.publish)"`
- `npm install bcrypt`

**Examples:**
- node -e "const D=require('dataloader');const l=new D(ids=>Promise.all(ids.map(id=>id*2)));Promise.all([l.load(1),l.load(2)]).then(console.log)"
- node -e "const g=require('graphql-subscriptions');const {PubSub}=g;const p=new PubSub();p.publish('EVENT',{id:1});console.log('published')"
- npm install dataloader graphql-subscriptions

### auth-integration
Protect GraphQL fields with JWT validation and directives

**Parameters:**
- `secret` (string): JWT secret
- `algorithm` (string): Signing algorithm

**Commands:**
- `npm install express-jwt`
- `node -e "const {expressjwt}=require('express-jwt');const m=expressjwt({secret:'s',algorithms:['HS256']});console.log(typeof m)"`
- `npm install graphql-directive-auth`
- `curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -H 'Authorization: Bearer bad' -d '{"query":"{ me { id } }"}'`
- `node -e "const j=require('jsonwebtoken');console.log(j.sign({sub:'u1'},'s',{expiresIn:'1h'}))"`

**Examples:**
- node -e "const {expressjwt}=require('express-jwt');const m=expressjwt({secret:'s',algorithms:['HS256']});console.log(typeof m)"
- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -H 'Authorization: Bearer bad' -d '{"query":"{ me { id } }"}'
- npm install graphql-directive-auth && npm install express-jwt

## References
- [DataLoader](https://github.com/graphql/dataloader)
- [GraphQL Subscriptions](https://the-guild.dev/graphql/subscriptions)
- [Apollo Server Auth](https://www.apollographql.com/docs/apollo-server/security/authentication/)

