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.
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 Summary
Modifier and TypeMethodDescriptionforSingleError(Function<Throwable, GraphQLError> resolver) Factory method to create aSubscriptionExceptionResolverto resolve an exception to a single GraphQL error.reactor.core.publisher.Mono<List<GraphQLError>>resolveException(Throwable exception) Resolve the given exception to a list ofGraphQLError's to be sent in an error message to the client.
-
Method Details
-
resolveException
Resolve the given exception to a list ofGraphQLError's to be sent in an error message to the client.- Parameters:
exception- the exception from the Publisher- Returns:
- a
Monowith the GraphQL errors to send to the client; if theMonocompletes with an empty List, the exception is resolved without any errors to send; if theMonocompletes empty, without emitting a List, the exception remains unresolved, and that allows other resolvers to resolve it.
-
forSingleError
static SubscriptionExceptionResolverAdapter forSingleError(Function<Throwable, GraphQLError> resolver) Factory method to create aSubscriptionExceptionResolverto resolve an exception to a single GraphQL error. Effectively, a shortcut for creatingSubscriptionExceptionResolverAdapterand overriding itsresolveToSingleErrormethod.- Parameters:
resolver- the resolver function to map the exception- Returns:
- the created instance
-