This repository was archived by the owner on Dec 19, 2023. It is now read-only.
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
No location, path, extensions When graphql.servlet.exception-handlers-enabled Set to true #478
Closed
Description
Version: 8.0.0
When graphql.servlet.exception-handlers-enabled
is set to true, validation errors do not contain location, path, or extensions. This is true with and with out @ExceptionHandler
s. In this scenario, my validation error is passing an integer to a parameter that requires a string.
When I set graphql.servlet.exception-handlers-enabled
to false, location, path, and extensions appear normally in the results for validation errors.
As a test, I made my application throw an IllegalArgumentException
and it was correctly picked up by my error handler and contained location, path, and extensions.
For reference, here is my error handler:
@Component
class ExceptionHandler {
@ExceptionHandler(Exception::class)
fun handleGeneric(ex: Exception, errorContext: ErrorContext): GraphQLError =
processGenericException(ex, errorContext)
private fun processGenericException(ex: Throwable, errorContext: ErrorContext): GraphQLError =
GraphqlErrorBuilder.newError()
.message(ex.message)
.locations(errorContext.locations.orEmpty())
.path(errorContext.path.orEmpty())
.extensions(errorContext.extensions.orEmpty())
.build()
}