Class ReactiveSecurityDataFetcherExceptionResolver

java.lang.Object
org.springframework.graphql.execution.ReactiveSecurityDataFetcherExceptionResolver
All Implemented Interfaces:
DataFetcherExceptionResolver

public class ReactiveSecurityDataFetcherExceptionResolver extends Object implements DataFetcherExceptionResolver
Reactive DataFetcherExceptionResolver for Spring Security exceptions. For use in applications with a reactive transport (e.g. WebFlux HTTP endpoint).
Since:
1.0.0
Author:
Rob Winch, Rossen Stoyanchev
  • Constructor Details

    • ReactiveSecurityDataFetcherExceptionResolver

      public ReactiveSecurityDataFetcherExceptionResolver()
  • Method Details

    • setAuthenticationTrustResolver

      public void setAuthenticationTrustResolver(org.springframework.security.authentication.AuthenticationTrustResolver trustResolver)
      Set the resolver to use to check if an authentication is anonymous that in turn determines whether AccessDeniedException is classified as "unauthorized" or "forbidden".
      Parameters:
      trustResolver - the resolver to use
    • resolveException

      public reactor.core.publisher.Mono<List<GraphQLError>> resolveException(Throwable ex, DataFetchingEnvironment environment)
      Description copied from interface: DataFetcherExceptionResolver
      Resolve the given exception and return the error(s) to add to the response.

      Implementations can use GraphqlErrorBuilder.newError(DataFetchingEnvironment) to create an error with the coordinates of the target field, and use ErrorType to specify a category for the error.

      Specified by:
      resolveException in interface DataFetcherExceptionResolver
      Parameters:
      ex - the exception to resolve
      environment - the environment for the invoked DataFetcher
      Returns:
      a Mono with errors to add to the GraphQL response; if the Mono completes with an empty List, the exception is resolved without any errors added to the response; if the Mono completes empty, without emitting a List, the exception remains unresolved and that allows other resolvers to resolve it.