Class SubscriptionExceptionResolverAdapter

java.lang.Object
org.springframework.graphql.execution.SubscriptionExceptionResolverAdapter
All Implemented Interfaces:
SubscriptionExceptionResolver

public abstract class SubscriptionExceptionResolverAdapter extends Object implements SubscriptionExceptionResolver
Adapter for SubscriptionExceptionResolver that pre-implements the asynchronous contract and exposes the following synchronous protected methods:

Applications may also use SubscriptionExceptionResolver.forSingleError(Function) as a shortcut for resolveToSingleError(Throwable).

Since:
1.0.1
Author:
Mykyta Ivchenko, Rossen Stoyanchev
See Also:
  • Field Details

    • logger

      protected final Log logger
  • Constructor Details

    • SubscriptionExceptionResolverAdapter

      public SubscriptionExceptionResolverAdapter()
  • Method Details

    • setThreadLocalContextAware

      public void setThreadLocalContextAware(boolean threadLocalContextAware)
      Subclasses can set this to indicate that ThreadLocal context from the transport handler (e.g. HTTP handler) should be restored when resolving exceptions.

      Note: This property is applicable only if transports use ThreadLocal's' (e.g. Spring MVC) and if a ThreadLocalAccessor is registered to extract ThreadLocal values of interest. There is no impact from setting this property otherwise.

      By default this is set to "false" in which case there is no attempt to propagate ThreadLocal context.

      Parameters:
      threadLocalContextAware - whether this resolver needs access to ThreadLocal context or not.
    • isThreadLocalContextAware

      public boolean isThreadLocalContextAware()
      Whether ThreadLocal context needs to be restored for this resolver.
    • resolveException

      public final reactor.core.publisher.Mono<List<GraphQLError>> resolveException(Throwable exception)
      Description copied from interface: SubscriptionExceptionResolver
      Resolve the given exception to a list of GraphQLError's to be sent in an error message to the client.
      Specified by:
      resolveException in interface SubscriptionExceptionResolver
      Parameters:
      exception - the exception from the Publisher
      Returns:
      a Mono with the GraphQL errors to send to the client; if the Mono completes with an empty List, the exception is resolved without any errors to send; if the Mono completes empty, without emitting a List, the exception remains unresolved, and that allows other resolvers to resolve it.
    • resolveToMultipleErrors

      @Nullable protected List<GraphQLError> resolveToMultipleErrors(Throwable exception)
      Override this method to resolve the Exception to multiple GraphQL errors.
      Parameters:
      exception - the exception to resolve
      Returns:
      the resolved errors or null if unresolved
    • resolveToSingleError

      @Nullable protected GraphQLError resolveToSingleError(Throwable exception)
      Override this method to resolve the Exception to a single GraphQL error.
      Parameters:
      exception - the exception to resolve
      Returns:
      the resolved error or null if unresolved