Skip to content
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
ryandanielspmc opened this issue Nov 12, 2020 · 0 comments
Labels
Milestone

Comments

@ryandanielspmc
Copy link

ryandanielspmc commented Nov 12, 2020

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 @ExceptionHandlers. 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()
}
@oliemansm oliemansm added this to the 8.1.0 milestone Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants