Interface SubscriptionExceptionResolver

All Known Implementing Classes:
SubscriptionExceptionResolverAdapter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SubscriptionExceptionResolver
Contract for a component that is invoked when a GraphQL subscription Publisher ends with an error.

Resolver implementations can extend the convenience base class SubscriptionExceptionResolverAdapter and override one of its methods resolveToSingleError or resolveToMultipleErrors that resolve the exception synchronously.

Resolved errors are wrapped in a SubscriptionPublisherException and propagated further to the underlying transport which access the errors and prepare a final error message to send to the client.

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

    • resolveException

      reactor.core.publisher.Mono<List<GraphQLError>> resolveException(Throwable exception)
      Resolve the given exception to a list of GraphQLError's to be sent in an error message to the client.
      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.
    • forSingleError

      Factory method to create a SubscriptionExceptionResolver to resolve an exception to a single GraphQL error. Effectively, a shortcut for creating SubscriptionExceptionResolverAdapter and overriding its resolveToSingleError method.
      Parameters:
      resolver - the resolver function to map the exception
      Returns:
      the created instance