# API GRAPHQL Specialist

> Deep GraphQL expertise: query planning, cost analysis, persisted queries, caching, and advanced security hardening. Use when working with query security, performance debugging or when the user mentions query security, performance debugging.

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

---


Deep GraphQL expertise: query planning, cost analysis, persisted queries, caching, and advanced security hardening.

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

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

### 1. Read — backend context for `api-graphql-specialist`
- Domain: Deep GraphQL expertise: query planning, cost analysis, persisted queries, caching, and advanced security hardening.
- **query-security**: Protect GraphQL APIs with complexity limits, depth limits, and persisted queries — `npm install graphql-cost-analysis`
- **performance-debugging**: Profile and fix N+1 queries, slow resolvers, and cache misses — `npx @apollo/server-plugin-response-cache --help || true`
- Check `knowledge` and `prerequisites: apollo-server, graphql-codegen, dataloader`

### 2. Reason — think for `api-graphql-specialist`
- For `query-security`: Protect GraphQL APIs with complexity limits, depth limits, and persisted queries — decide which checks to run
- For `performance-debugging`: Profile and fix N+1 queries, slow resolvers, and cache misses — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

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

# API GraphQL Specialist

Deep expertise in running GraphQL at scale: security, performance, and client efficiency.

## When to Use
- Expensive or abusive queries
- N+1 and slow-resolver issues
- Hardening GraphQL in production

## Real Commands

```bash
# Cost analysis
npm install graphql-query-complexity

# Hardening bundle
npm install @escape.tech/graphql-armor

# Benchmark a query
curl -s -X POST http://localhost:4001/graphql -H 'Content-Type: application/json' -d '{"query":"{ products { id name } }"}' -w '\n%{time_total}s'

# Schema audits
graphql-inspector audit docs/query.graphql schema.graphql
```

## Security Config
- `maxDepth: 10` — reject deep nesting
- `maxCost: 1000` — reject expensive queries
- Persisted queries to shrink attack surface

## Performance Playbook
1. Reproduce with curl timing
2. Add DataLoader for batch reads
3. Cache resolvers by field and TTL
4. Re-benchmark and compare

## Best Practices
- Reject unknown queries in production
- Log slow queries above a threshold
- Run schema audit in CI

## Capabilities

### query-security
Protect GraphQL APIs with complexity limits, depth limits, and persisted queries

**Parameters:**
- `maxCost` (string): Maximum query cost
- `maxDepth` (string): Maximum query depth

**Commands:**
- `npm install graphql-cost-analysis`
- `node -e "const {costAnalysisPlugin}=require('@graphql-community/graphql-query-cost');console.log(typeof costAnalysisPlugin)"`
- `npm install @escape.tech/graphql-armor`
- `node -e "const a=require('@escape.tech/graphql-armor');console.log(Object.keys(a))"`
- `npm install graphql-query-complexity`

**Examples:**
- npm install graphql-query-complexity && node -e "const c=require('graphql-query-complexity');console.log(typeof c)"
- npm install @escape.tech/graphql-armor
- node -e "const a=require('@escape.tech/graphql-armor');const s=a.enableGraphQLArmor();console.log(Object.keys(s))"

### performance-debugging
Profile and fix N+1 queries, slow resolvers, and cache misses

**Parameters:**
- `query` (string): GraphQL query to benchmark
- `endpoint` (string): GraphQL endpoint URL

**Commands:**
- `npx @apollo/server-plugin-response-cache --help || true`
- `node --trace-gc server.js 2>&1 | grep -i 'gc ' | head`
- `curl -s -X POST http://localhost:4001/graphql -H 'Content-Type: application/json' -d '{"query":"{ products { id name } }"}' -w '\n%{time_total}s'`
- `graphql-inspector audit docs/query.graphql schema.graphql`
- `npx apollo --version`

**Examples:**
- curl -s -X POST http://localhost:4001/graphql -H 'Content-Type: application/json' -d '{"query":"{ products { id name } }"}' -w '\n%{time_total}s'
- graphql-inspector audit docs/query.graphql schema.graphql
- node --trace-gc server.js 2>&1 | grep -i 'GC' | head -20

## References
- [GraphQL Armor](https://escape.tech/blog/graphql-armor/)
- [Apollo Server Docs](https://www.apollographql.com/docs/apollo-server/)
- [GraphQL Inspector](https://the-guild.dev/graphql/inspector/docs)

