Bug? instrumentExecutionContext not called for subscriptions #358
Description
Hello,
I have defined an own Instrumentation, which overrides method instrumentExecutionContext to provide a customized ExecutionContext prior query execution.
class ExecutionContextInstrumentation extends SimpleInstrumentation {
@Override
public ExecutionContext instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters) {
...
return myExecutionContext;
}
}
@Service
class InstrumentationService {
@Bean
List<Instrumentation> instrumentations() {
return new ArrayList<>(List.of(new ExecutionContextInstrumentation());
}
}
This works perfectly fine when executing GraphQL queries and mutations. However, that method is not called when I execute a subscription. It's working for subscriptions though, if I execute my code outside of the Spring context, e.g. in a plain-vanilla JUnit test. So it does not seem to be a bug in graphql-java, but in the graphql-java-kickstart
, which does not take my instrumentation bean for subscriptions.
So to make it clear: This plain graphql-java code works fine for subscriptions as well.
graphQL = GraphQL.newGraphQL(schema)
.instrumentation(new ExecutionContextInstrumentation())
.build();
But within the context of graphql-spring-boot
I have no way to set the instrumentations explicitly. I have to define a bean of type List<Instrumentation>
, which returns the instrumentations. The framework then cares about the wiring.