In development mode, the Router is configured to be as verbose as possible, providing extensive information to help with debugging and troubleshooting. This mode exposes additional details about subgraph errors, making it easier to identify the root causes of issues.
Wrapped mode
By default, the Router operates in wrapped mode, where errors are encapsulated in a generic error object. This indicates a problem with the subgraph, while more detailed error information is provided in theerrors
field within the extensions
object.
Default Configuration
extensions
field is not exposed. In the extension object we only passthrough the code
field. For more detailed error output, you can modify the configuration as follow:
Extended Configuration Options
Example Error Response with Extended Configuration
attach_service_name
option allows the affected subgraph’s name to be sent to the client, which can help in generating more informative error messages.
Avoid exposing any information
The wrapped mode is useful when you want to avoid exposing additional information about subgraph errors to the client. This mode provides a generic error response without revealing specific details. You can enable this by using the following configuration: ConfigurationPassthrough mode
The **pass-through **mode returns errors exactly as they are received from the subgraph, without modification. This mode is commonly used in the GraphQL ecosystem to provide more transparency in error responses. As described in the previous section, you can fine-tune what information is exposed by adjusting the configuration.Propagate only selected error fields
You can also select which fields are propagated withallowed_fields
. The following fields are always propagated:
message
path
omit_extensions
is set to true
(default is false
), extensions
will not be propagated. This is useful in case you want to avoid leaking internal information to the client. Some users of GraphQL leverage the errors.extensions.code field to implement error handling logic in the client, in which case you might want to set this to false.
If omit_locations
is set to true
(default is false
), locations
will not be propagated. This is useful because the locations of a Subgraph error is internal to the Subgraph and not relevant to the client.
Propagate only selected error extension fields
You can select which fields are propagated withallowed_extension_fields
. The following fields are propagated by default:
code
allow_all_extension_fields
is set to true
(default is false
), all extension fields will be propagated. allow_all_extension_fields
takes precedence over allowed_extension_fields
, but omit_extensions
overrules both.
Configuration
Fallback status code errors
In cases where the router cannot parse a properly formed error from the subgraph response, e.g.- A proxy is returning a non-JSON response like HTML, or plain text.
- A subgraph is returning JSON, but not valid GraphQL errors or data.
status_code
are preserved if enabled.