·
Last changedVersion:
This version passed the hardening gate. Hardening applied 2 targeted changes, normalized allowed-tools to the canonical single-string form, and preserved all other text. Classified findings before hardening: 2. Classified findings closed: 0. Classified findings remaining: 2. Unclassified scanner findings remaining: 0. Review findings closed: 2. Review findings remaining: 9.
2
2
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Memory & Context Poisoning | — | Medium | Open | |
SKILL.md | Prompt Injection | Direct prompt injection | Medium | Open |
2 findings
Create native Rust plugins for Apollo Router.
| Service | Description |
|---|---|
| Runs at the very beginning and very end of the HTTP request lifecycle.For example, JWT authentication is performed within the RouterService.Define router_service if your customization needs to interact with HTTP context and headers. |
| Runs at the very beginning and very end of the GraphQL request lifecycle.Define supergraph_service if your customization needs to interact with the GraphQL request or the GraphQL response. For example, you can add a check for anonymous queries. |
| Handles initiating the execution of a query plan after it's been generated.Define execution_service if your customization includes logic to govern execution (for example, if you want to block a particular query based on a policy decision). |
| Handles communication between the router and your subgraphs.Define subgraph_service to configure this communication (for example, to dynamically add HTTP headers to pass to a subgraph).Whereas other services are called once per client request, this service is called once per subgraph request that's required to resolve the client's request. Each call is passed a subgraph parameter that indicates the name of the corresponding subgraph. |
Signatures:
Use ServiceBuilder to compose these hooks within any service:
| Hook | Purpose | Sync/Async |
|---|---|---|
| Transform request before proceeding | Sync |
| Transform response before returning | Sync |
| Validate/filter, can short-circuit | Sync |
| Async validation, can short-circuit | Async |
| Enable service cloning (needed for async) | - |
| Add tracing span around service | - |
| Control request throughput | - |
| Set operation time limit | - |
By data needed:
router_servicesupergraph_serviceexecution_servicesubgraph_serviceBy timing:
router_service requestsupergraph_service requestexecution_service requestsubgraph_servicerouter_service responseSee references/service-hooks.md for implementation patterns.
Create a new file src/plugins/my_plugin.rs with required imports:
Every plugin needs a configuration struct with Deserialize and JsonSchema derives. The JsonSchema enables configuration validation in editors:
Implement the Plugin trait with the required Config type and new constructor:
Choose which service(s) to hook based on your requirements, see Service Overview for details.
Example service hook:
At the bottom of your plugin file, register it with the router:
In src/plugins/mod.rs, add your module:
Enable your plugin in the router configuration:
For implementation patterns and code examples, see references/service-hooks.md:
map_request, map_response)checkpoint_async, buffered)Located in the Apollo Router plugins directory:
| Plugin | Service Hook | Pattern | Description |
|---|---|---|---|
|
| checkpoint | Simple gate on query plan |
| execution + supergraph | Context passing | Multi-service coordination |
|
| HTTP layer | CORS handling at HTTP level |
|
| Layer composition | Complex header manipulation |
For full code examples and testing patterns, see references/examples.md.
Get started with chainctlchainctl skill install public/apollographql/apollo-router-plugin-creator:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/apollographql/skills/apollo-router-plugin-creator:latest
MIT
HARDENING.md
LICENSE
SKILL.md
references/examples.md
references/existing-plugins.md
references/service-hooks.md