Add DataFetcherExceptionResolverAdapter

The adapter aims to:
- simplify the common case of synchronous resolution to a single error
- support ThreadLocal context propagation on an opt-in basis

This replaces the SyncDataFetcherExceptionResolver and removes the need
to propagate ThreadLocal context to every resolver.
This commit is contained in:
Rossen Stoyanchev
2021-07-05 19:35:04 +01:00
parent a6211bda93
commit bac7461678
8 changed files with 186 additions and 92 deletions

View File

@@ -271,6 +271,11 @@ by the <<execution-graphqlsource>> builder. It enables applications to register
more Spring `DataFetcherExceptionResolver` components that are invoked sequentially
until one resolves the `Exception` to a list of `graphql.GraphQLError` objects.
`DataFetcherExceptionResolver` is an asynchronous contract. For most implementations, it
would be sufficient to extend `DataFetcherExceptionResolverAdapter` and override
one of its `resolveToSingleError` or `resolveToMultipleErrors` methods that
resolve exceptions synchronously.
A `GraphQLError` can be assigned an `graphql.ErrorClassification`. Spring GraphQL
defines an `ErrorType` enum with common, error classification categories: