apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
807 stars 272 forks source link

Allow arbitrary keys on error messages from subgraphs #4439

Open CamBowes opened 9 months ago

CamBowes commented 9 months ago

Is your feature request related to a problem? Please describe. Hi, I've been working on an issue where when an error occurs on our raw subgraph, we get some extra information like the following returned to the client (correllationId, sessionID etc) which are placed outside the graphql spec: { "errors": [ { "message": "REDACTED service error: 400", "cause": { "name": "RemoteServiceError", "statusCode": 400, "message": "REDACTED service error: 400", "errorCodes": [], "errorDescriptions": [], "errorDetails": [], "errorReasons": [], "contentErrorCodes": [], "rootCause": [] }, "locations": [ { "line": 3, "column": 5 } ], "path": [ "REDACTED", "REDACTED" ], "source": { "body": "REDACTED", "name": "GraphQL request", "locationOffset": { "line": 1, "column": 1 } }, "correlationId": "REDACTED", "sessionId": "REDACTED", "callId": "REDACTED", "serviceName": "REDACTED", "severity": "FATAL", "attemptsRemaining": 0 } ], "data": { "REDACTED": { "REDACTED": null } } }

When we do the same request to the router, all of this extra information is omitted from the router's response.

We've tried writing a rhai script to combat this and we've also tried a Rust Plugin to no avail as it seems the router gets rid of this info before it gets to custom code.

Describe the solution you'd like It would be appreciated if the Router could be tweaked to allow for arbitrary keys to be passed through from the subgraph to the client via the router

Describe alternatives you've considered As described above, we have tried a custom Rhai script and Rust Plugin to no avail.

Additional context We do not have the capacity to rewrite all our client code to move these custom keys elsewhere.

o0Ignition0o commented 9 months ago

Hi, thanks for raising this issue!

It looks related to #2110, which has discussion around how the router should behave in this sort of siguation. We are trying to find the right balance between verbosity and security, and we'd love to get your opinions and thoughts!