All skills
apollographql avatar

/apollo-router-plugin-creator

@7be6130 official
by Apollo GraphQLapollographql/skills115 stars
13

Guide for writing Apollo Router native Rust plugins. Use this skill when: (1) users want to create a new router plugin, (2) users want to add service hooks (router_service, supergraph_service, execution_service, subgraph_service), (3) users want to modify an existing router plugin, (4) users need to understand router plugin patterns or the request lifecycle. (5) triggers on requests like "create a new plugin", "add a router plugin", "modify the X plugin", or "add subgraph_service hook".

Use this Skill: https://skilld.dev/gh/apollographql/skills/apollo-router-plugin-creator

This session only. Nothing lands on disk.

referencesexisting-plugins.md

≈439 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Existing Plugins Reference

Reference plugins from the Apollo Router open-source plugins directory. Use as reference when creating new plugins.

Discovering Plugins

Browse the Apollo Router plugins directory for the full list of built-in plugins.

Find plugins by service hook in a local checkout of the Apollo Router repo:

# Plugins with router_service
grep -r "fn router_service" apollo-router/src/plugins/

# Plugins with supergraph_service
grep -r "fn supergraph_service" apollo-router/src/plugins/

# Plugins with subgraph_service
grep -r "fn subgraph_service" apollo-router/src/plugins/

Configuration Patterns

Simple Boolean

// introspection_gate.rs
#[derive(Debug, Default, Deserialize, JsonSchema)]
struct Config {
  enabled: bool,
  proxy_request_header: String
}

With Optional Fields

// header_plugin.rs
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
struct Config {
  enabled: bool,
  subgraphs_allowed_to_set_cookie: Option<Arc<HashSet<String>>>
}

Nested Configuration

// add_extensions.rs
#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]
struct Extensions {
  name: String,
  rename_as: Option<String>
}

#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]
struct Config {
  enabled: bool,
  extensions_to_forward: Arc<Vec<Extensions>>
}

Per-Subgraph Configuration

// subgraph_circuit_breaker
#[derive(Debug, Clone, Deserialize, JsonSchema)]
struct Config {
  enabled: bool,
  default: CircuitBreakerSettings,
  subgraphs: HashMap<String, CircuitBreakerSettings>
}

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides educational guidance and code templates for developing Apollo Router plugins. All external references target the vendor's official trusted repositories, and the provided code follows standard development practices for the platform.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    3/4 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7be6130. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 8 months ago
All 1 allowed tools
Read Write Edit Glob Grep
Other metadata
metadata
{
  "author": "apollographql",
  "version": "1.0.0",
  "compatibility": "Requires Apollo Router with native plugin support"
}
  • Rust
  • apollo-router
  • graphql
  • plugins
  • authentication
  • middleware
  • request-lifecycle
  • subgraph
  • tower

README badge

README badge for apollographql/skills/apollo-router-plugin-creator

Guides writing native Rust plugins for Apollo Router that hook into the request lifecycle via router_service, supergraph_service, execution_service, and subgraph_service. Use this to add authentication, request validation, query plan control, or per-subgraph request modification.

Generated from the current SKILL.md.

Which service hook should I use to modify HTTP headers?
Use router_service, which runs at the beginning and end of the HTTP request lifecycle and has access to HTTP context and headers.
Can I access the GraphQL query and variables in a plugin?
Yes, use supergraph_service, which runs at the beginning and end of the GraphQL request lifecycle and can inspect and modify the GraphQL request and response.
How do I add custom logic for each subgraph request?
Use subgraph_service, which is called once per subgraph request and receives the subgraph name, allowing you to configure per-subgraph communication like dynamically adding headers.
What language are Apollo Router plugins written in?
Plugins are written in Rust and compile as native plugins for Apollo Router.
Can I add rate limiting or timeouts in a plugin?
Yes, Tower layers like rate_limit and timeout are available to compose within any service hook.

Generated from the current SKILL.md. These answers refresh after source changes.