@@ -64,14 +64,17 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par
6464
6565 @ Override
6666 public DataFetcher <?> instrumentDataFetcher (
67- DataFetcher <?> dataFetcher , InstrumentationFieldFetchParameters parameters ) {
68- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
67+ DataFetcher <?> dataFetcher ,
68+ InstrumentationFieldFetchParameters parameters ,
69+ InstrumentationState instrumentationState ) {
70+ DataLoaderDispatcherInstrumentationState state =
71+ InstrumentationState .ofState (instrumentationState );
6972 if (state .isAggressivelyBatching ()) {
7073 return dataFetcher ;
7174 }
7275 //
7376 // currently only AsyncExecutionStrategy with DataLoader and hence this allows us to "dispatch"
74- // on every object if its not using aggressive batching for other execution strategies
77+ // on every object if it's not using aggressive batching for other execution strategies
7578 // which allows them to work if used.
7679 return (DataFetcher <Object >)
7780 environment -> {
@@ -87,12 +90,14 @@ private void doImmediatelyDispatch(DataLoaderDispatcherInstrumentationState stat
8790
8891 @ Override
8992 public InstrumentationContext <ExecutionResult > beginExecuteOperation (
90- InstrumentationExecuteOperationParameters parameters ) {
93+ InstrumentationExecuteOperationParameters parameters ,
94+ InstrumentationState instrumentationState ) {
9195 if (!isDataLoaderCompatible (parameters .getExecutionContext ())) {
92- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
96+ DataLoaderDispatcherInstrumentationState state =
97+ InstrumentationState .ofState (instrumentationState );
9398 state .setAggressivelyBatching (false );
9499 }
95- return new SimpleInstrumentationContext <> ();
100+ return SimpleInstrumentationContext . noOp ();
96101 }
97102
98103 private boolean isDataLoaderCompatible (ExecutionContext executionContext ) {
@@ -111,8 +116,10 @@ private boolean isDataLoaderCompatible(ExecutionContext executionContext) {
111116
112117 @ Override
113118 public ExecutionStrategyInstrumentationContext beginExecutionStrategy (
114- InstrumentationExecutionStrategyParameters parameters ) {
115- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
119+ InstrumentationExecutionStrategyParameters parameters ,
120+ InstrumentationState instrumentationState ) {
121+ DataLoaderDispatcherInstrumentationState state =
122+ InstrumentationState .ofState (instrumentationState );
116123 //
117124 // if there are no data loaders, there is nothing to do
118125 //
@@ -134,21 +141,25 @@ public void onCompleted(ExecutionResult result, Throwable t) {
134141
135142 @ Override
136143 public InstrumentationContext <Object > beginFieldFetch (
137- InstrumentationFieldFetchParameters parameters ) {
138- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
144+ InstrumentationFieldFetchParameters parameters , InstrumentationState instrumentationState ) {
145+ DataLoaderDispatcherInstrumentationState state =
146+ InstrumentationState .ofState (instrumentationState );
139147 //
140148 // if there are no data loaders, there is nothing to do
141149 //
142150 if (state .hasNoDataLoaders ()) {
143- return new SimpleInstrumentationContext <> ();
151+ return SimpleInstrumentationContext . noOp ();
144152 }
145153 return state .getApproach ().beginFieldFetch (parameters );
146154 }
147155
148156 @ Override
149157 public CompletableFuture <ExecutionResult > instrumentExecutionResult (
150- ExecutionResult executionResult , InstrumentationExecutionParameters parameters ) {
151- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
158+ ExecutionResult executionResult ,
159+ InstrumentationExecutionParameters parameters ,
160+ InstrumentationState instrumentationState ) {
161+ DataLoaderDispatcherInstrumentationState state =
162+ InstrumentationState .ofState (instrumentationState );
152163 state .getApproach ().removeTracking (parameters .getExecutionInput ().getExecutionId ());
153164 if (!options .isIncludeStatistics ()) {
154165 return CompletableFuture .completedFuture (executionResult );
0 commit comments