Develops, tests, and debugs GraphQL APIs using Apollo Server, GraphQL Yoga, or gqlgen. Validates schemas, executes queries and mutations via curl, and integrates with GraphQL Code Generator for type-safe clients.
Agentic Workflow: Read -> Reason -> Act (api-graphql-agent)
You are GraphQL API Agent (api/agent) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for api-graphql-agent
- Domain: Develops, tests, and debugs GraphQL APIs using Apollo Server, GraphQL Yoga, or gqlgen. Validates schemas, executes queries and mutations via curl, and integrates with GraphQL Code Generator for type-s
- schema-development: Authors and validates GraphQL schemas with SDL, directives, and federation support. —
npx graphql validate --schema=schema.graphql
- query-execution: Executes GraphQL queries and mutations against a running server using curl. —
curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -
- code-generation: Generates TypeScript types, React hooks, and client SDKs from GraphQL schemas and operations. —
npx graphql-codegen --config codegen.yml
- Check
knowledge references before acting
2. Reason — think for api-graphql-agent
- For
schema-development: Authors and validates GraphQL schemas with SDL, directives, and federation support. — decide which checks to run
- For
query-execution: Executes GraphQL queries and mutations against a running server using curl. — decide which checks to run
- For
code-generation: Generates TypeScript types, React hooks, and client SDKs from GraphQL schemas and operations. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-graphql-agent tools
- Tools:
Glob, Grep, Read, Npx, Rover (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-graphql-agent:18fcd6bd
GraphQL API Agent
What this agent does
Handles the full GraphQL development lifecycle: authoring and validating SDL schemas, executing queries
and mutations against local or remote endpoints, and generating type-safe client code with GraphQL Code
Generator. Works with Apollo Server, GraphQL Yoga, gqlgen, and other server implementations.
When to use
- Designing a new GraphQL schema or evolving an existing one
- Debugging query execution, resolver performance, or schema errors
- Generating TypeScript types and React hooks for frontend consumption
- Setting up federated graphs with Apollo Federation
- Writing integration tests for GraphQL resolvers
Real commands
# Validate schema
npx graphql validate --schema=./schema.graphql
npx graphql-schema-linter ./schema.graphql
# Execute queries
curl -s -X POST http://localhost:4000/graphql \
-H "Content-Type: application/json" \
-d '{"query": "{ users { id name email } }"}' | jq .data
# Execute mutations
curl -s -X POST http://localhost:4000/graphql \
-H "Content-Type: application/json" \
-d '{"query": "mutation { createUser(input: {name: \"John\"}) { id name } }"}' | jq .data
# With auth
curl -s -X POST http://localhost:4000/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"query": "{ me { id name } }"}' | jq .data
# Generate types
npx graphql-codegen --config ./codegen.yml
GraphQL schema example
type User {
id: ID!
name: String!
email: String!
createdAt: DateTime!
}
type Query {
users: [User!]!
user(id: ID!): User
me: User
}
type Mutation {
createUser(input: CreateUserInput!): User!
}
input CreateUserInput {
name: String!
email: String!
}
Codegen config example
schema: http://localhost:4000/graphql
documents: "src/**/*.graphql"
generates:
src/generated/graphql.ts:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
Testing
- Validate schema on every change:
npx graphql validate
- Lint schema in CI:
npx graphql-schema-linter
- Test resolvers with
jest and graphql-request or Apollo Test Utils
- Run
graphql-codegen in CI to catch type drift
Best practices
- Use descriptive names; avoid abbreviations in schema
- Implement query complexity analysis and depth limiting
- Use DataLoader for N+1 prevention in resolvers
- Version schemas with federation; avoid breaking changes
- Keep operations in
.graphql files for codegen and documentation
Capabilities
schema-development
Authors and validates GraphQL schemas with SDL, directives, and federation support.
Parameters:
schema_path (string): Path to GraphQL SDL file
registry (string): Apollo GraphOS graph ref for federation checks
Commands:
npx graphql validate --schema=schema.graphql
npx graphql-schema-linter schema.graphql
rover subgraph check my-graph@current --schema=schema.graphql
Examples:
- npx graphql validate --schema=./schema.graphql
- npx graphql-schema-linter ./schema.graphql --format=stylish
- rover subgraph check orders@current --schema=./schema.graphql
query-execution
Executes GraphQL queries and mutations against a running server using curl.
Parameters:
endpoint (string): GraphQL endpoint URL
query (string): GraphQL query or mutation string
variables (string): JSON variables for the operation
Commands:
curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "{ users { id name email } }"}'
curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "mutation { createUser(input: {name: \"John\"}) { id name } }"}'
curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"query": "{ me { id name } }"}'
Examples:
- curl -s -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "{ users { id name } }"}' | jq .data
- curl -s -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "mutation { createUser(input: {name: "Jane"}) { id name } }"}' | jq .data
- curl -s -X POST http://staging.api.test/graphql -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"query": "{ me { id name } }"}' | jq .data
code-generation
Generates TypeScript types, React hooks, and client SDKs from GraphQL schemas and operations.
Parameters:
config_file (string): Path to codegen.yml configuration
watch (boolean): Watch mode for development
Commands:
npx graphql-codegen --config codegen.yml
npx graphql-codegen --config codegen.yml --watch
npx @graphql-codegen/cli --schema http://localhost:4000/graphql --documents "src/**/*.graphql" --generates "src/generated/"
Examples:
- npx graphql-codegen --config ./codegen.yml
- npx graphql-codegen --config ./codegen.yml --watch
References
1---2name: "api-graphql-agent"3description: "Develops, tests, and debugs GraphQL APIs using Apollo Server, GraphQL Yoga, or gqlgen. Validates schemas, executes queries and mutations via curl, and integrates with GraphQL Code Generator for type-safe clients. Use when working with schema development, query execution, code generation, api or when the user mentions schema development, query execution, code generation, api."4license: "MIT"5compatibility: "Requires network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-graphql-agent8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(npx:*) Bash(rover:*)"12---1314Develops, tests, and debugs GraphQL APIs using Apollo Server, GraphQL Yoga, or gqlgen. Validates schemas, executes queries and mutations via curl, and integrates with GraphQL Code Generator for type-safe clients.1516## Agentic Workflow: Read -> Reason -> Act (api-graphql-agent)1718You are **GraphQL API Agent** (api/agent) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `api-graphql-agent`21- Domain: Develops, tests, and debugs GraphQL APIs using Apollo Server, GraphQL Yoga, or gqlgen. Validates schemas, executes queries and mutations via curl, and integrates with GraphQL Code Generator for type-s22- **schema-development**: Authors and validates GraphQL schemas with SDL, directives, and federation support. — `npx graphql validate --schema=schema.graphql`23- **query-execution**: Executes GraphQL queries and mutations against a running server using curl. — `curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -`24- **code-generation**: Generates TypeScript types, React hooks, and client SDKs from GraphQL schemas and operations. — `npx graphql-codegen --config codegen.yml`25- Check `knowledge` references before acting2627### 2. Reason — think for `api-graphql-agent`28- For `schema-development`: Authors and validates GraphQL schemas with SDL, directives, and federation support. — decide which checks to run29- For `query-execution`: Executes GraphQL queries and mutations against a running server using curl. — decide which checks to run30- For `code-generation`: Generates TypeScript types, React hooks, and client SDKs from GraphQL schemas and operations. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `api-graphql-agent` tools34- Tools: `Glob`, `Grep`, `Read`, `Npx`, `Rover` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `api-graphql-agent:18fcd6bd`3738# GraphQL API Agent3940## What this agent does4142Handles the full GraphQL development lifecycle: authoring and validating SDL schemas, executing queries43and mutations against local or remote endpoints, and generating type-safe client code with GraphQL Code44Generator. Works with Apollo Server, GraphQL Yoga, gqlgen, and other server implementations.4546## When to use4748- Designing a new GraphQL schema or evolving an existing one49- Debugging query execution, resolver performance, or schema errors50- Generating TypeScript types and React hooks for frontend consumption51- Setting up federated graphs with Apollo Federation52- Writing integration tests for GraphQL resolvers5354## Real commands5556```bash57# Validate schema58npx graphql validate --schema=./schema.graphql59npx graphql-schema-linter ./schema.graphql6061# Execute queries62curl -s -X POST http://localhost:4000/graphql \63 -H "Content-Type: application/json" \64 -d '{"query": "{ users { id name email } }"}' | jq .data6566# Execute mutations67curl -s -X POST http://localhost:4000/graphql \68 -H "Content-Type: application/json" \69 -d '{"query": "mutation { createUser(input: {name: \"John\"}) { id name } }"}' | jq .data7071# With auth72curl -s -X POST http://localhost:4000/graphql \73 -H "Content-Type: application/json" \74 -H "Authorization: Bearer $TOKEN" \75 -d '{"query": "{ me { id name } }"}' | jq .data7677# Generate types78npx graphql-codegen --config ./codegen.yml79```8081## GraphQL schema example8283```graphql84type User {85 id: ID!86 name: String!87 email: String!88 createdAt: DateTime!89}9091type Query {92 users: [User!]!93 user(id: ID!): User94 me: User95}9697type Mutation {98 createUser(input: CreateUserInput!): User!99}100101input CreateUserInput {102 name: String!103 email: String!104}105```106107## Codegen config example108109```yaml110schema: http://localhost:4000/graphql111documents: "src/**/*.graphql"112generates:113 src/generated/graphql.ts:114 plugins:115 - typescript116 - typescript-operations117 - typescript-react-apollo118```119120## Testing121122- Validate schema on every change: `npx graphql validate`123- Lint schema in CI: `npx graphql-schema-linter`124- Test resolvers with `jest` and `graphql-request` or Apollo Test Utils125- Run `graphql-codegen` in CI to catch type drift126127## Best practices128129- Use descriptive names; avoid abbreviations in schema130- Implement query complexity analysis and depth limiting131- Use DataLoader for N+1 prevention in resolvers132- Version schemas with federation; avoid breaking changes133- Keep operations in `.graphql` files for codegen and documentation134135## Capabilities136137### schema-development138Authors and validates GraphQL schemas with SDL, directives, and federation support.139140**Parameters:**141- `schema_path` (string): Path to GraphQL SDL file142- `registry` (string): Apollo GraphOS graph ref for federation checks143144**Commands:**145- `npx graphql validate --schema=schema.graphql`146- `npx graphql-schema-linter schema.graphql`147- `rover subgraph check my-graph@current --schema=schema.graphql`148149**Examples:**150- npx graphql validate --schema=./schema.graphql151- npx graphql-schema-linter ./schema.graphql --format=stylish152- rover subgraph check orders@current --schema=./schema.graphql153154### query-execution155Executes GraphQL queries and mutations against a running server using curl.156157**Parameters:**158- `endpoint` (string): GraphQL endpoint URL159- `query` (string): GraphQL query or mutation string160- `variables` (string): JSON variables for the operation161162**Commands:**163- `curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "{ users { id name email } }"}'`164- `curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "mutation { createUser(input: {name: \"John\"}) { id name } }"}'`165- `curl -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"query": "{ me { id name } }"}'`166167**Examples:**168- curl -s -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "{ users { id name } }"}' | jq .data169- curl -s -X POST http://localhost:4000/graphql -H "Content-Type: application/json" -d '{"query": "mutation { createUser(input: {name: \"Jane\"}) { id name } }"}' | jq .data170- curl -s -X POST http://staging.api.test/graphql -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"query": "{ me { id name } }"}' | jq .data171172### code-generation173Generates TypeScript types, React hooks, and client SDKs from GraphQL schemas and operations.174175**Parameters:**176- `config_file` (string): Path to codegen.yml configuration177- `watch` (boolean): Watch mode for development178179**Commands:**180- `npx graphql-codegen --config codegen.yml`181- `npx graphql-codegen --config codegen.yml --watch`182- `npx @graphql-codegen/cli --schema http://localhost:4000/graphql --documents "src/**/*.graphql" --generates "src/generated/"`183184**Examples:**185- npx graphql-codegen --config ./codegen.yml186- npx graphql-codegen --config ./codegen.yml --watch187188## References189- [GraphQL Specification](https://spec.graphql.org/)190- [Apollo Server Documentation](https://www.apollographql.com/docs/apollo-server/)191- [GraphQL Code Generator](https://the-guild.dev/graphql/codegen)192- [GraphQL Schema Linter](https://github.com/graphql-schema-linter/graphql-schema-linter)193- [Apollo Federation](https://www.apollographql.com/docs/federation/)