-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extensions field to error response #171
base: main
Are you sure you want to change the base?
Conversation
…ng, Any?>? 2. Added "error type" to make it easy to branch by error types at the client side. 3. Added debug mode. If true, exception information will be output in extensions when an error occurs. 4. Embed serialize function to GraphQLError class because we want to use GraphQLError individually. ex: at StatusPages Plugin.
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 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 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
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 stuebingerb/KGraphQL@bc01867 |
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.