Hector Gonzalez
09/15/2020, 7:30 PMDariusz Kuc
09/16/2020, 4:52 AMgraphql-kotlin
or graphql-java
it should be the same as in non-federated service
• for error handling you probably want to specify your own DataFetcherExceptionHandler
• for logging (if it is something that you want to configure globally) you could use instrumentationHector Gonzalez
09/17/2020, 3:14 PMgraphql-kotlin
I've tried implementing `DataFetcherExceptionHandler`without success.Hector Gonzalez
09/17/2020, 3:15 PMexception-handlers-enabled: true
I've also created a class to handle exceptions like this:Hector Gonzalez
09/17/2020, 3:15 PM@Component
class CustomGraphQlErrorHandler: DataFetcherExceptionHandler {
private val logger = LoggerFactory.getLogger(CustomGraphQlErrorHandler::class.java)
@ExceptionHandler
override fun onException(handlerParameters: DataFetcherExceptionHandlerParameters?): DataFetcherExceptionHandlerResult {
val exception= handlerParameters?.exception
val sourceLocation= handlerParameters?.sourceLocation
val path= handlerParameters?.path
val error = ExceptionWhileDataFetching(path, exception, sourceLocation)
return DataFetcherExceptionHandlerResult.newResult().error(error).build()
}
}
Dariusz Kuc
09/17/2020, 3:29 PMexception-handlers-enabled
property as it is not something we use within the libraryDariusz Kuc
09/17/2020, 3:29 PMDariusz Kuc
09/17/2020, 3:29 PMgraphql-kotlin-spring-server
?Hector Gonzalez
09/17/2020, 3:36 PMgraphql-kotlin-spring-server
I'm not sure if the way I'm trying to trigger that code may be wrong though.
What I'm currently doing is trying to retrieve a non-existing field in our schema. And that does triggers a validation error, but the code in the handler doesn't seem to execute.Hector Gonzalez
09/17/2020, 3:47 PMHector Gonzalez
09/17/2020, 3:47 PM{
"errors": [
{
"message": "Validation error of type FieldUndefined: Field 'categoryNames' in type 'Category' is undefined @ 'getCategoryById/categoryNames'",
"locations": [
{
"line": 4,
"column": 5
}
]
}
]
}
Dariusz Kuc
09/17/2020, 3:59 PMDariusz Kuc
09/17/2020, 4:00 PMDariusz Kuc
09/17/2020, 4:00 PMgraphql-java
logic there so you can take a look at their documentation but I don’t recall any way to customize validation exception handlingHector Gonzalez
09/17/2020, 4:09 PM