Fixed deferred support to have proper Instrumentation#4083
Conversation
Test Results 325 files - 650 325 suites - 650 3m 29s ⏱️ - 7m 7s Results for commit 215be0b. ± Comparison against base commit 3ba9750. This pull request removes 541 and adds 172 tests. Note that renamed tests count towards both.This pull request skips 1 test.♻️ This comment has been updated with latest results. |
| ExecutionContext executionContext, | ||
| BiFunction<ExecutionContext, ExecutionStrategyParameters, CompletableFuture<FieldValueInfo>> resolveFieldWithInfoFn | ||
| BiFunction<ExecutionContext, ExecutionStrategyParameters, CompletableFuture<FieldValueInfo>> resolveFieldWithInfoFn, | ||
| BiFunction<ExecutionContext, ExecutionStrategyParameters, Supplier<ExecutionStepInfo>> executionStepInfoFn |
There was a problem hiding this comment.
I need to be able to build the ExecutionStepInfo later and this allows me to do that back in the execution strategy
| key -> FpKit.interThreadMemoize(() -> { | ||
| CompletableFuture<FieldValueInfo> fieldValueResult = resolveFieldWithInfoFn.apply(executionContext, executionStrategyParameters); | ||
| key -> FpKit.interThreadMemoize(resolveDeferredFieldValue(currentField, executionContext, executionStrategyParameters) | ||
| ) |
There was a problem hiding this comment.
moved most of the code into a method resolveDeferredFieldValue - just because it was a lambda in a lambda
| public InstrumentationContext<Object> beginDeferredField(InstrumentationState instrumentationState) { | ||
| return new ChainedDeferredExecutionStrategyInstrumentationContext(chainedMapAndDropNulls(instrumentationState, Instrumentation::beginDeferredField)); | ||
| public InstrumentationContext<Object> beginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) { | ||
| return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginDeferredField(parameters, specificState)); |
There was a problem hiding this comment.
This was just wrong and it had not tests
| @ExperimentalApi | ||
| default InstrumentationContext<Object> beginDeferredField(InstrumentationState state) { | ||
| default InstrumentationContext<Object> beginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) { | ||
| return noOp(); |
There was a problem hiding this comment.
we now have field parameters
|
|
||
| private Supplier<ExecutionStepInfo> createExecutionStepInfo(ExecutionContext executionContext, ExecutionStrategyParameters parameters) { | ||
| GraphQLFieldDefinition fieldDef = getFieldDef(executionContext, parameters, parameters.getField().getSingleField()); | ||
| return FpKit.intraThreadMemoize(() -> createExecutionStepInfo(executionContext, parameters, fieldDef, null)); |
There was a problem hiding this comment.
I need to be able to create a ExecutionStepInfo for a field but later
The current deferred field Instrumentation is broken - it has no arguments and its context is never called back.
This implements it more properly. It calls beingDeferredField each time a field actually gets started - eg after the main operation has finished and we begin to drain the deferred queue