Customizations for the Apollo Router
Extend your router with custom functionality
You can create customizations for the Apollo Router to add functionality that isn't available via built-in configuration options. For example, you can make an external call to fetch authentication data for each incoming request.
Customization types
The Apollo Router supports the following customization types:
- Rhai scripts
- The Rhai scripting language enables you to add functionality directly to your stock router binary by hooking into different phases of the router's request lifecycle.
- External co-processing (Enterprise feature)
- If your organization has a GraphOS Enterprise plan, you can write custom request-handling code in any language. This code can run in the same container as your router or separately.
- The router calls your custom code via HTTP, passing it the details of each incoming client request.
Use Rhai scripts if they support your use case. External co-processing is most helpful if your customization needs to do any of the following (which Rhai scripts don't support):
- Read or write to disk
- Make network requests
- Use libraries from a particular language or framework
Next, see the documentation for your preferred customization type.