Subgraph Error Inclusion
Configure the router to propagate subgraph errors to clients
By default, a GraphOS Router or Apollo Router Core redacts the details of subgraph errors in responses to clients. The router instead returns a default error with the following message:
1Subgraph errors redactedThis redaction prevents potential leaks of sensitive information to the client. Using the include_subgraph_errors plugin, you can configure the router to propagate subgraph errors to clients instead. You can do this for all subgraphs, or on a per-subgraph basis.
Configuration
To configure subgraph error inclusion, add the include_subgraph_errors plugin to your YAML config file, like so:
1include_subgraph_errors:
2 all: true # Propagate errors from all subgraphs
3 subgraphs:
4 products: false # Do not propagate errors from the products subgraphAny configuration under the subgraphs key takes precedence over configuration under the all key. In the example above, subgraph errors are included from all subgraphs except the products subgraph.
Sending errors to GraphOS
To report the subgraph errors to GraphOS that is a separate configuration that is not affected by client subgraph error inclusion, see the GraphOS reporting docs.
Logging GraphQL request errors
To log the GraphQL error responses (i.e. messages returned in the GraphQL errors array) from the router, see the logging configuration documentation.
Exposing subgraph name through error extensions
If include_subgraph_errors is true for a particular subgraph, all errors originating in this subgraph will have the subgraph's name exposed as a service extension.
For example, if subgraph errors are enabled for the products subgraph and this subgraph returns an error, it will have a service extension:
1{
2 "data": null,
3 "errors": [
4 {
5 "message": "Invalid product ID",
6 "path": [],
7 "extensions": {
8 "service": "products",
9 }
10 }
11 ]
12}