Open ima9dan opened 2 years ago
This would be a very welcome change!
Hey @ima9dan. I also implemented extensions in #166, but your solutions seems more advanced, because my solution don't support other types than string for extension values. I will close my merge request and point to that one! :)
@jeggy requested a unit test to prove that the solution works. That probably would also make sense here.
fyi, changes 1 and 3 have been taken over with https://github.com/stuebingerb/KGraphQL/commit/bc0186767753498b111a5053d68b13b64111692c
Change 1: Added extensions to the error response. Change 2: Added debug option to GraphQL Configuration (flag to output exception information to extensions) Change 3: Moved serialize (), which was defined as an extension of GraphQLError, into GraphQLError. option
Change 1: Added extensions to the error response.
fields in extensions.
ex1:
output
ex2:
output
Change 2: Added debug option to GraphQL Configuration (flag to output exception information to extensions)
First, set the debug option to true when installing GraphQL
Then raise GraphQLError
Finaly, the debug field is automatically added to extensions, and the detailed information of exception is output.
Change 3: Moved serialize (), which was defined as an extension function of GraphQLError, into GraphQLError. option
I want to move serialize () to use GraphQLError outside the KGraphQL plugin. For example, KGraphQL relies on an external plugin for authentication processing. In that case, if an authentication error occurs, 401 will occur and you will not be able to return a response in the general GraphQL error format.
Therefore, I would like to do the following. In the StatusPages plugin, I want to create a GraphQLError and use the serialize () to make it json and respond. For that, serialize () wants to go inside GraphQLError.