[JAVA] When you want to notify an error somewhere when using graphql-spring-boot in Spring Boot

I couldn't get it with @ RestControllerAdvice, and I wanted a little more detailed information than @ExceptionHandler.


val spring_version=2.2.2.RELEASE


Code example

It seems good to register Map <String, ExecutionStrategy> in the bean.

class GraphQLConfig {
    fun executionStrategies(): Map<String, ExecutionStrategy> {
        val customDataFetcherExceptionHandler = CustomDataFetcherExceptionHandler
        return mapOf(
                "queryExecutionStrategy" to AsyncExecutionStrategy(customDataFetcherExceptionHandler),
                "mutationExecutionStrategy" to AsyncSerialExecutionStrategy(customDataFetcherExceptionHandler)

    class CustomDataFetcherExceptionHandler: SimpleDataFetcherExceptionHandler() {
        override fun onException(handlerParameters: DataFetcherExceptionHandlerParameters): DataFetcherExceptionHandlerResult {
            //Notify me nicely
            //If you want lower level information
            // handlerParameters.dataFetchingEnvironment.getContext<GraphQLServletContext>().It seems that you can get it with httpServletRequest.
            return super.onException(handlerParameters)

I'm still not sure if ʻAsyncExecutionStrategy and ʻAsyncSerialExecutionStrategy are okay, but for now I can skip the error to slack or something.

Please comment if there is a better way.

Recommended Posts

When you want to notify an error somewhere when using graphql-spring-boot in Spring Boot
ProxyFactory is convenient when you want to test AOP in Spring!
Unknown error in line 1 of pom.xml when using Spring Boot in Eclipse
I want to display an error message when registering in the database
When you want to bind InputStream in JDBI3
If you want to separate Spring Boot + Thymeleaf processing
When you want to dynamically replace Annotation in Java8
Customize the display when an error such as 404 Not Found occurs in Spring Boot
Get error information using DefaultErrorAttributes and ErrorAttributeOptions in Spring Boot 2.3
How to control transactions in Spring Boot without using @Transactional
Things to note when using Spring AOP in Jersery resource classes
How to solve the unknown error when using slf4j in Java
I want to control the default error message of Spring Boot
What to do and how to install when an error occurs in DXRuby 1.4.7
Story when moving from Spring Boot 1.5 to 2.1
Error in implementation when implementing Spring validation
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
My memorandum that I want to make ValidationMessages.properties UTF8 in Spring Boot
How to not start Flyway when running unit tests in Spring Boot
What to do if you get an error when you hit Heroku logs
Javaw.exe error when starting Spring Boot (STS)
When introducing JOOQ to Spring boot, a story that was dealt with because an error occurred around Liquibase
I get an error when I try to use "^" or "$" in ruby ​​regular expression
[Error resolution] Occurs when trying to build an environment for spring with docker
Summary when trying to use Solr in Java and getting an error (Solr 6.x)
407 error when trying to access an HTTPS site in Java via an authenticated proxy
When using a list in Java, java.awt.List comes out and an error occurs
I want to send an email in Java.
A note when you want Tuple in Java
When you want to use the method outside
When deploying to Heroku, OpenApp causes an error
How to add a classpath in Spring Boot
An introduction to Spring Boot + in-memory data grid
[Swift] Use nonzeroBitCount when you want popcnt in Swift
How to bind to property file in Spring Boot
Apply Twitter Bootstrap 4 to Spring Boot 2 using Webjars
[Ruby] When you want to replace multiple characters
[Rails] What to do when you want to generate an error that cannot be destory when foreign key restrictions are applied
I want you to put the story that the error was solved when you stabbed the charger in the corner of your head
I want to issue a connection when a database is created using Spring and MyBatis
Until you create a Spring Boot project in Intellij and push it to Github
Code to use when you want to process Json with only standard library in Java
Things to keep in mind when using if statements
An introductory book to read when you start Rails
Extend Spring Boot DefaultErrorViewResolver to dynamically customize error screens
How to use CommandLineRunner in Spring Batch of Spring Boot
Test field-injected class in Spring boot test without using Spring container
Until you start development with Spring Boot in eclipse 1
Introduce swagger-ui to REST API implemented in Spring Boot
If you want to recreate the instance in cloud9
Until you start development with Spring Boot in eclipse 2
[Spring Dtata JPA] How to deal with the problem that DB change cannot be detected when you want to process API synchronously with a single thread in Spring Boot.
[Ruby + Rails] When you want to register in Mailchimp's mail list together with user registration
How to write in Model class when you want to save binary data in DB with PlayFramework
I want to control the maximum file size in file upload for each URL in Spring Boot
When you want to implement Java library testing in Spock with multi-module in Gradle in Android Studio 3
What to do if you get an error in Basic authentication during Rails test code
When you want to reflect the Master Branch information in the Current Branch you are currently working on
What to do if you get an error saying Cannot find a valid baseurl for repo when you use yum -y install docker in a udemy course using CentOS7
I got an error when using nextInt, nextLine and substring.