# AGENTS.md — `hyperlane-plugin-graphql`
Concise engineering and iteration guidelines for `hyperlane-plugin-graphql` (`plugin/graphql/`).
Global rules live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md), [`../README.md`](../README.md), and `~/.agents/skills/rust-standards/SKILL.md`.
## Scope & Module Boundaries
- **Role**: Zero-external-parser GraphQL over HTTP (`POST`/`GET`) engine with depth/complexity DoS caps, `XxHash3_64` query/mutation resolver registries, sub-field projection, and `GraphqlHook`.
- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros` (keep parser free of external parser crates).
- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`GRAPHQL_PLUGIN`, recursive descent parser, and `project_selection` stay `pub(crate)`); tests in `tests/`.
## Core Iteration Invariants
- **Hook contract & order**: `GraphqlHook` (`#[hyperlane::request_middleware(-62)]`) MUST match `config.endpoint` (default `"/graphql"`) exactly, return `Status::Continue` when unconfigured or on other paths, and send JSON bytes before returning `Status::Reject`.
- **Three-tier parser DoS caps**: Enforce `query.len() <= max_query_bytes` before parsing, and enforce `max_depth >= 1` (covering both nested selection sets and nested list/object input values) plus total `max_fields >= 1`.
- **GraphQL-over-HTTP method rules**: Disallow mutations on `GET` (`allow_mutation = false`), and return HTTP `405 Method Not Allowed` for unsupported methods.
- **Strict projection & partial-error semantics**: Strip unrequested object/array keys via `project_selection`, emit keys using `FieldSelection::response_key()` (alias over name), and return per-field `null` + `errors` for resolver failures while returning `data: None` on syntax/DoS/method violations.
## Code & Documentation Standards
- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs`, centralized imports in `src/lib.rs` and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no `self.field`), explicit types on all `let`/closure bindings, zero `#[allow]`/`unwrap()`/`expect()`/`panic!()`, `pub` before `pub(crate)` in `const.rs`/`static.rs`, strict `Cargo.toml` dependency order, and comment-free tests in `tests/`.
- Keep all code, comments, docs, and commits pure English. Update `plugin/graphql/README.md` (and `plugin/README.md` / root `README.md` if hook order or public surface changes) in the same commit.
## Local Verification
```sh
cargo run -p hyperlane-cli -- fmt --check
cargo clippy -p hyperlane-plugin-graphql --all-features --all-targets -- -D warnings
cargo test -p hyperlane-plugin-graphql --all-features
python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py .
python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py .
```