public interface DataFetcherExceptionResolver
DataFetcher
s.
Implementations are typically declared as beans in Spring configuration and
are invoked sequentially until one emits a List of GraphQLError
s.
Most resolver implementations can extend
DataFetcherExceptionResolverAdapter
and override one of its
resolveToSingleError
or
resolveToMultipleErrors
methods that resolve the exception synchronously.
Resolver implementations can use ErrorType
to classify errors
using one of several common categories.
ErrorType
,
DataFetcherExceptionResolverAdapter
,
ExceptionResolversExceptionHandler
Modifier and Type | Method and Description |
---|---|
static DataFetcherExceptionResolverAdapter |
forSingleError(BiFunction<Throwable,DataFetchingEnvironment,GraphQLError> resolver)
Factory method to create a
DataFetcherExceptionResolver to resolve
an exception to a single GraphQL error. |
reactor.core.publisher.Mono<List<GraphQLError>> |
resolveException(Throwable exception,
DataFetchingEnvironment environment)
Resolve the given exception and return the error(s) to add to the response.
|
reactor.core.publisher.Mono<List<GraphQLError>> resolveException(Throwable exception, DataFetchingEnvironment environment)
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.
exception
- the exception to resolveenvironment
- the environment for the invoked DataFetcher
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.static DataFetcherExceptionResolverAdapter forSingleError(BiFunction<Throwable,DataFetchingEnvironment,GraphQLError> resolver)
DataFetcherExceptionResolver
to resolve
an exception to a single GraphQL error. Effectively, a shortcut
for creating DataFetcherExceptionResolverAdapter
and overriding
its resolveToSingleError
method.resolver
- the resolver function to use