BACK TO TEMPLATES
rulesany

GraphQL and Apollo Server Rules

Backend AGENTS.md for GraphQL APIs covering schema-first design, DataLoader batching, and complexity limits.

When to use this

Place in GraphQL server repositories to enforce DataLoader batching (preventing N+1 queries) and query complexity caps.

The template

# AGENTS.md

## Project Context

GraphQL API server built with Node.js, Apollo Server 4, TypeScript, and Prisma ORM.

## Commands

- `npm run dev` start GraphQL dev server with Apollo Studio sandbox
- `npm run codegen` generate TypeScript types from GraphQL schema
- `npm test` run resolver unit tests

Run `npm run codegen` and `npm test` before declaring changes complete.

## Conventions

- Prevent N+1 relational queries by batching requests through `DataLoader` instances.
- Define GraphQL schema in `.graphql` SDL files under `src/schema/`.
- Enforce query depth and query complexity plugins on Apollo Server.

## Restrictions

- Do not perform direct database queries inside field resolvers without DataLoader wrappers.
- Do not expose database internal primary keys directly; use Global Node IDs.

How to use

Save to repository root as AGENTS.md.

Last verified 2026-07-26