Annotation Interface GraphQlExceptionHandler


@Target(METHOD) @Retention(RUNTIME) @Documented public @interface GraphQlExceptionHandler
Declares a method as a handler of exceptions raised while fetching data for a field. When declared in an @Controller, it applies to @SchemaMapping methods of that controller only. When declared in an @ControllerAdvice it applies across controllers.

You can also use annotated exception handler methods in @ControllerAdvice beans to handle exceptions from non-controller DataFetchers by obtaining AnnotatedControllerDetectionSupport.getExceptionResolver() and registering it with GraphQlSource.Builder.

Supported return types are listed in the Spring for GraphQL reference documentation in the section "Annotated Controllers".

Since:
1.2.0
Author:
Rossen Stoyanchev
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<? extends Throwable>[]
    Exceptions handled by the annotated method.
  • Element Details

    • value

      Class<? extends Throwable>[] value
      Exceptions handled by the annotated method. If empty, defaults to exception types declared in the method signature.
      Default:
      {}