@@ -64,14 +64,17 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par
64
64
65
65
@ Override
66
66
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 );
69
72
if (state .isAggressivelyBatching ()) {
70
73
return dataFetcher ;
71
74
}
72
75
//
73
76
// 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
75
78
// which allows them to work if used.
76
79
return (DataFetcher <Object >)
77
80
environment -> {
@@ -87,12 +90,14 @@ private void doImmediatelyDispatch(DataLoaderDispatcherInstrumentationState stat
87
90
88
91
@ Override
89
92
public InstrumentationContext <ExecutionResult > beginExecuteOperation (
90
- InstrumentationExecuteOperationParameters parameters ) {
93
+ InstrumentationExecuteOperationParameters parameters ,
94
+ InstrumentationState instrumentationState ) {
91
95
if (!isDataLoaderCompatible (parameters .getExecutionContext ())) {
92
- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
96
+ DataLoaderDispatcherInstrumentationState state =
97
+ InstrumentationState .ofState (instrumentationState );
93
98
state .setAggressivelyBatching (false );
94
99
}
95
- return new SimpleInstrumentationContext <> ();
100
+ return SimpleInstrumentationContext . noOp ();
96
101
}
97
102
98
103
private boolean isDataLoaderCompatible (ExecutionContext executionContext ) {
@@ -111,8 +116,10 @@ private boolean isDataLoaderCompatible(ExecutionContext executionContext) {
111
116
112
117
@ Override
113
118
public ExecutionStrategyInstrumentationContext beginExecutionStrategy (
114
- InstrumentationExecutionStrategyParameters parameters ) {
115
- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
119
+ InstrumentationExecutionStrategyParameters parameters ,
120
+ InstrumentationState instrumentationState ) {
121
+ DataLoaderDispatcherInstrumentationState state =
122
+ InstrumentationState .ofState (instrumentationState );
116
123
//
117
124
// if there are no data loaders, there is nothing to do
118
125
//
@@ -134,21 +141,25 @@ public void onCompleted(ExecutionResult result, Throwable t) {
134
141
135
142
@ Override
136
143
public InstrumentationContext <Object > beginFieldFetch (
137
- InstrumentationFieldFetchParameters parameters ) {
138
- DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
144
+ InstrumentationFieldFetchParameters parameters , InstrumentationState instrumentationState ) {
145
+ DataLoaderDispatcherInstrumentationState state =
146
+ InstrumentationState .ofState (instrumentationState );
139
147
//
140
148
// if there are no data loaders, there is nothing to do
141
149
//
142
150
if (state .hasNoDataLoaders ()) {
143
- return new SimpleInstrumentationContext <> ();
151
+ return SimpleInstrumentationContext . noOp ();
144
152
}
145
153
return state .getApproach ().beginFieldFetch (parameters );
146
154
}
147
155
148
156
@ Override
149
157
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 );
152
163
state .getApproach ().removeTracking (parameters .getExecutionInput ().getExecutionId ());
153
164
if (!options .isIncludeStatistics ()) {
154
165
return CompletableFuture .completedFuture (executionResult );
0 commit comments