@@ -420,6 +420,8 @@ public CompletableFuture<ExecutionResult> executeAsync(UnaryOperator<ExecutionIn
420420 * @return a promise to an {@link ExecutionResult} which can include errors
421421 */
422422 public CompletableFuture <ExecutionResult > executeAsync (ExecutionInput executionInput ) {
423+ Profiler profiler = executionInput .isProfileExecution () ? new ProfilerImpl (executionInput .getGraphQLContext ()) : Profiler .NO_OP ;
424+ profiler .start ();
423425 EngineRunningState engineRunningState = new EngineRunningState (executionInput );
424426 return engineRunningState .engineRun (() -> {
425427 ExecutionInput executionInputWithId = ensureInputHasId (executionInput );
@@ -439,7 +441,7 @@ public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput executionI
439441
440442 GraphQLSchema graphQLSchema = instrumentation .instrumentSchema (this .graphQLSchema , instrumentationParameters , instrumentationState );
441443
442- CompletableFuture <ExecutionResult > executionResult = parseValidateAndExecute (instrumentedExecutionInput , graphQLSchema , instrumentationState , engineRunningState );
444+ CompletableFuture <ExecutionResult > executionResult = parseValidateAndExecute (instrumentedExecutionInput , graphQLSchema , instrumentationState , engineRunningState , profiler );
443445 //
444446 // finish up instrumentation
445447 executionResult = executionResult .whenComplete (completeInstrumentationCtxCF (executionInstrumentation ));
@@ -471,7 +473,7 @@ private ExecutionInput ensureInputHasId(ExecutionInput executionInput) {
471473 }
472474
473475
474- private CompletableFuture <ExecutionResult > parseValidateAndExecute (ExecutionInput executionInput , GraphQLSchema graphQLSchema , InstrumentationState instrumentationState , EngineRunningState engineRunningState ) {
476+ private CompletableFuture <ExecutionResult > parseValidateAndExecute (ExecutionInput executionInput , GraphQLSchema graphQLSchema , InstrumentationState instrumentationState , EngineRunningState engineRunningState , Profiler profiler ) {
475477 AtomicReference <ExecutionInput > executionInputRef = new AtomicReference <>(executionInput );
476478 Function <ExecutionInput , PreparsedDocumentEntry > computeFunction = transformedInput -> {
477479 // if they change the original query in the pre-parser, then we want to see it downstream from then on
@@ -484,7 +486,7 @@ private CompletableFuture<ExecutionResult> parseValidateAndExecute(ExecutionInpu
484486 return CompletableFuture .completedFuture (new ExecutionResultImpl (preparsedDocumentEntry .getErrors ()));
485487 }
486488 try {
487- return execute (executionInputRef .get (), preparsedDocumentEntry .getDocument (), graphQLSchema , instrumentationState , engineRunningState );
489+ return execute (executionInputRef .get (), preparsedDocumentEntry .getDocument (), graphQLSchema , instrumentationState , engineRunningState , profiler );
488490 } catch (AbortExecutionException e ) {
489491 return CompletableFuture .completedFuture (e .toExecutionResult ());
490492 }
@@ -548,13 +550,14 @@ private CompletableFuture<ExecutionResult> execute(ExecutionInput executionInput
548550 Document document ,
549551 GraphQLSchema graphQLSchema ,
550552 InstrumentationState instrumentationState ,
551- EngineRunningState engineRunningState
553+ EngineRunningState engineRunningState ,
554+ Profiler profiler
552555 ) {
553556
554557 Execution execution = new Execution (queryStrategy , mutationStrategy , subscriptionStrategy , instrumentation , valueUnboxer , responseMapFactory , doNotAutomaticallyDispatchDataLoader );
555558 ExecutionId executionId = executionInput .getExecutionId ();
556559
557- return execution .execute (document , graphQLSchema , executionId , executionInput , instrumentationState , engineRunningState );
560+ return execution .execute (document , graphQLSchema , executionId , executionInput , instrumentationState , engineRunningState , profiler );
558561 }
559562
560563}
0 commit comments