Open lleadbet opened 1 year ago
Hmm that's because it's not really part of the specs https://spec.graphql.org/October2021/#note-5c13b we should investigate what we want to accept or move into extensions
Fair, although this is something that AS3/4 both can do out of the box. The above Rhai might be the only solution, but we should document it as such.
It is part of the spec Oct2021 for both response.extensions and response.errors[].extensions.
@lleadbet is your subgraph response invalid in this example though? Shouldn't it be for the query { getUser { id } }
{
"errors": [
{
"code": "TEST_CODE",
"message": "Code isn't a defined root field value, but okay according to the specification...",
"extensions": {
"test": 1
}
}
],
"data": {
"getUser": {
"id": null
}
},
"extensions": {
"2": "hullo",
"test": 1234
}
}
Yeah, I had updated it at some point to return:
{
"data": {
"getError": "null"
},
"extensions": {
"2": "hullo",
test: 1234,
}
}
which still exhibits the same issue here (missing response.extensions
)
@bnjjj As noted above, response.extensions
is indeed a spec-valid thing — we even use it in the Router to return query plans when running in --dev
mode. I don't think that we necessarily want to move anything new into extensions
, but it is surface area that users should be able to use if they want.
Fwiw, I can't tell if you're suggesting this was the case or not, but I didn't/don't think that the Gateway ever established or supported any method for exposing extensions
returned from subgraphs — mostly because that gets very squarely into "stomping on each other's extensions" territory without thoughtfully ordered rules on how those should be merged.
We feel this can be done via Rhai. Let's validate that and document it.
Describe the bug It appears the Router is currently stripping the root level extensions field from the response to clients, even though subgraphs are responding with them in the request.
To Reproduce
Given this dummy subgraph:
and this supergraph:
If you query the server directly, you get:
However the router returns:
It is possible to work around this using Rhai currently, however:
Expected behavior This feels as though it should be supported natively, either as a config option or by default.