Do not send stack traces in GraphQL responses #1539
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short description
To remove the stack traces from the Graphql errors, I had to remove the usage of
GraphqlErrorException
as it always serializes the whole exception including stacktrace.Proposed changes
Make
GraphQLBaseException
no longer inherit from the above mentionedGraphqlErrorException
and implement a custom DataFetcherExceptionHandler that only wraps unknown exceptions intoExceptionWhileDataFetching
objects and converts the known ones (ie. the subclasses of GraphQLBaseException) into GraphQLErrors without wrapping it.If an ExceptionWhileDataFetching occurs, the wrapped exception is rethrown and either handled by
handle
if it's a 40x error, or by Javalin (if it's a completely unexpected exception) and then a 500 is returned and the exception is logged by Javalin.Side effects
Hopefully none.
Resolved issues
Fixes: #1538