Closed MaaxGr closed 2 years ago
Tested it. Everything works:
throw GraphQLError(message = "test", extensions = mapOf("code" to "BAD_USER_INPUT"))
Returns:
{
"errors": [
{
"message": "test",
"locations": [],
"path": [],
"extensions": {
"code": "BAD_USER_INPUT"
}
}
]
}
Hi @MaaxGr
This looks great! Could you write a unit test that validates that your implementation also works?
Sorry for this late response.
Haha. Yeah of course. Hopefully that also doesn't have to wait for some months :D Let's see, when I have time for that
Sure :) And I'm gonna make sure that this repository won't stand stale again.
We have opened GitHub discussions and I'm looking for people to help out #187 Looking for maintainers
Hey. I have added a unit test to verify the serialize()-Method with extensions
-Object included.
But to be honest i now realize that the implementation doesn't exactly matches the spec.
GraphQL services may provide an additional entry to errors with key extensions. This entry, if set, must have a map as its value. This entry is reserved for implementors to add additional information to errors however they see fit, and there are no additional restrictions on its contents. https://spec.graphql.org/June2018/#example-90475
This example shows that there can also be substructures in one extension, which is currently not supported in my implementation. https://www.apollographql.com/docs/apollo-server/data/errors/
How sould we deal with this?
Closing this, as we probably should go with MR #171.
Fixes #165