Make it easier to configure `ExecutionStrategy`
org.springframework.graphql.execution.ExceptionResolversExceptionHandler is package private, and it's not exposed as a Bean. Clearly it's designed that way.
I'm trying to extend graphql.execution.AsyncExecutionStrategy and override
@Override
protected CompletableFuture<ExecutionResult> completeValueForEnum(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLEnumType enumType, Object result)
{
}
to ignore unknown enum values in a class called IgnoreUnknownEnumValueExecutionStrategy. But the difficulty, without duplicating ExceptionResolversExceptionHandler, is I could not inject the ExceptionResolversExceptionHandler instance (which is hidden within the framework) into my IgnoreUnknownEnumValueExecutionStrategy bean.
Please advise if my use case and question is legitimate. Thanks.
I think this is the same case as #552. There we provided the static factory method DataFetcherExceptionResolver#createExceptionHandler to create the ExceptionResolversExceptionHandler instance.
We could try to take this a step further by facilitating the registration of execution strategies with the the DataFetcherExceptionHandler that we create. Something like this on GraphQlSource.Builder:
Builder configureExecutionStrategies(BiConsumer<GraphQL.Builder, DataFetcherExceptionHandler> configurer);
Or perhaps even a dedicated ExecutionStrategyFactory to create an ExecutionStrategy given a DataFetcherExceptionHandler. Although something like that could belong in GraphQL Java too.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Thank you @rstoyanchev for your response. I'll update our version to take advantage of DataFetcherExceptionResolver#createExceptionHandler since it is currently at 1.0.3.
You can decide on the further refinement you mentioned.
I'll update the title to reflect the actual goal to make it easier to configure a custom ExecutionStrategy. We need to consider whether to make a change here, or to request an enhancement in GraphQL Java's GraphQL.Builder. I'll leave this open for the time being.
On further thought, a callback on GraphQlSource.Builder limits the ability to declare an ExecutionStrategy as a Spring bean while at the same time there isn't much of a drawback to create DataFetcherExceptionHandler via DataFetcherExceptionResolver#createExceptionHandler. It's mostly about making it easier to discover.
I'm turning this into a documentation issue. I'll update the Javadoc and reference docs to make it easy to find.
Fixed via aa1ee77867aee19bedef1f7eb5451fe46fc1c5e4