Skip to content

Commit 2496fa1

Browse files
authored
Merge pull request #3460 from graphql-java/git-rid-of-er-wrapping
Removed the deprecated Instrumentation methods and removes ER wrapping
2 parents d5eb160 + 2ab2181 commit 2496fa1

31 files changed

+111
-983
lines changed

src/main/java/graphql/GraphQL.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,10 @@ public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput executionI
417417
CompletableFuture<InstrumentationState> instrumentationStateCF = instrumentation.createStateAsync(new InstrumentationCreateStateParameters(this.graphQLSchema, executionInputWithId));
418418
return Async.orNullCompletedFuture(instrumentationStateCF).thenCompose(instrumentationState -> {
419419
try {
420-
InstrumentationExecutionParameters inputInstrumentationParameters = new InstrumentationExecutionParameters(executionInputWithId, this.graphQLSchema, instrumentationState);
420+
InstrumentationExecutionParameters inputInstrumentationParameters = new InstrumentationExecutionParameters(executionInputWithId, this.graphQLSchema);
421421
ExecutionInput instrumentedExecutionInput = instrumentation.instrumentExecutionInput(executionInputWithId, inputInstrumentationParameters, instrumentationState);
422422

423-
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(instrumentedExecutionInput, this.graphQLSchema, instrumentationState);
423+
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(instrumentedExecutionInput, this.graphQLSchema);
424424
InstrumentationContext<ExecutionResult> executionInstrumentation = nonNullCtx(instrumentation.beginExecution(instrumentationParameters, instrumentationState));
425425
executionInstrumentation.onDispatched();
426426

@@ -442,7 +442,7 @@ public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput executionI
442442

443443
private CompletableFuture<ExecutionResult> handleAbortException(ExecutionInput executionInput, InstrumentationState instrumentationState, AbortExecutionException abortException) {
444444
CompletableFuture<ExecutionResult> executionResult = CompletableFuture.completedFuture(abortException.toExecutionResult());
445-
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema, instrumentationState);
445+
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema);
446446
//
447447
// allow instrumentation to tweak the result
448448
executionResult = executionResult.thenCompose(result -> instrumentation.instrumentExecutionResult(result, instrumentationParameters, instrumentationState));
@@ -504,7 +504,7 @@ private PreparsedDocumentEntry parseAndValidate(AtomicReference<ExecutionInput>
504504
}
505505

506506
private ParseAndValidateResult parse(ExecutionInput executionInput, GraphQLSchema graphQLSchema, InstrumentationState instrumentationState) {
507-
InstrumentationExecutionParameters parameters = new InstrumentationExecutionParameters(executionInput, graphQLSchema, instrumentationState);
507+
InstrumentationExecutionParameters parameters = new InstrumentationExecutionParameters(executionInput, graphQLSchema);
508508
InstrumentationContext<Document> parseInstrumentationCtx = nonNullCtx(instrumentation.beginParse(parameters, instrumentationState));
509509
parseInstrumentationCtx.onDispatched();
510510

@@ -523,7 +523,7 @@ private ParseAndValidateResult parse(ExecutionInput executionInput, GraphQLSchem
523523
}
524524

525525
private List<ValidationError> validate(ExecutionInput executionInput, Document document, GraphQLSchema graphQLSchema, InstrumentationState instrumentationState) {
526-
InstrumentationContext<List<ValidationError>> validationCtx = nonNullCtx(instrumentation.beginValidation(new InstrumentationValidationParameters(executionInput, document, graphQLSchema, instrumentationState), instrumentationState));
526+
InstrumentationContext<List<ValidationError>> validationCtx = nonNullCtx(instrumentation.beginValidation(new InstrumentationValidationParameters(executionInput, document, graphQLSchema), instrumentationState));
527527
validationCtx.onDispatched();
528528

529529
Predicate<Class<?>> validationRulePredicate = executionInput.getGraphQLContext().getOrDefault(ParseAndValidate.INTERNAL_VALIDATION_PREDICATE_HINT, r -> true);

src/main/java/graphql/analysis/MaxQueryComplexityInstrumentation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.jetbrains.annotations.Nullable;
1515

1616
import java.util.List;
17+
import java.util.concurrent.CompletableFuture;
1718
import java.util.concurrent.atomic.AtomicReference;
1819
import java.util.function.Function;
1920

@@ -78,11 +79,10 @@ public MaxQueryComplexityInstrumentation(int maxComplexity, FieldComplexityCalcu
7879
}
7980

8081
@Override
81-
public InstrumentationState createState(InstrumentationCreateStateParameters parameters) {
82-
return new State();
82+
public @Nullable CompletableFuture<InstrumentationState> createStateAsync(InstrumentationCreateStateParameters parameters) {
83+
return CompletableFuture.completedFuture(new State());
8384
}
8485

85-
8686
@Override
8787
public @Nullable InstrumentationContext<List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState rawState) {
8888
State state = ofState(rawState);

src/main/java/graphql/execution/Execution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public CompletableFuture<ExecutionResult> execute(Document document, GraphQLSche
110110
executionContext.getGraphQLContext().put(ResultNodesInfo.RESULT_NODES_INFO, executionContext.getResultNodesInfo());
111111

112112
InstrumentationExecutionParameters parameters = new InstrumentationExecutionParameters(
113-
executionInput, graphQLSchema, instrumentationState
113+
executionInput, graphQLSchema
114114
);
115115
executionContext = instrumentation.instrumentExecutionContext(executionContext, parameters, instrumentationState);
116116
return executeOperation(executionContext, executionInput.getRoot(), executionContext.getOperationDefinition());

src/main/java/graphql/execution/SubscriptionExecutionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private CompletableFuture<ExecutionResult> executeSubscriptionEvent(ExecutionCon
145145

146146
// allow them to instrument each ER should they want to
147147
InstrumentationExecutionParameters i13nExecutionParameters = new InstrumentationExecutionParameters(
148-
executionContext.getExecutionInput(), executionContext.getGraphQLSchema(), executionContext.getInstrumentationState());
148+
executionContext.getExecutionInput(), executionContext.getGraphQLSchema());
149149

150150
overallResult = overallResult.thenCompose(executionResult -> instrumentation.instrumentExecutionResult(executionResult, i13nExecutionParameters, executionContext.getInstrumentationState()));
151151
return overallResult;

src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
*
4444
* @see graphql.execution.instrumentation.Instrumentation
4545
*/
46-
@SuppressWarnings("deprecation")
4746
@PublicApi
4847
public class ChainedInstrumentation implements Instrumentation {
4948

@@ -112,72 +111,33 @@ protected void chainedConsume(InstrumentationState state, BiConsumer<Instrumenta
112111
}
113112
}
114113

115-
@Override
116-
public InstrumentationState createState() {
117-
return Assert.assertShouldNeverHappen("createStateAsync should only ever be used");
118-
}
119-
120-
@Override
121-
public @Nullable InstrumentationState createState(InstrumentationCreateStateParameters parameters) {
122-
return Assert.assertShouldNeverHappen("createStateAsync should only ever be used");
123-
}
124-
125114
@Override
126115
public @NotNull CompletableFuture<InstrumentationState> createStateAsync(InstrumentationCreateStateParameters parameters) {
127116
return ChainedInstrumentationState.combineAll(instrumentations, parameters);
128117
}
129118

130-
@Override
131-
@NotNull
132-
public InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters) {
133-
// these assert methods have been left in so that we truly never call these methods, either in production nor in tests
134-
// later when the deprecated methods are removed, this will disappear.
135-
return Assert.assertShouldNeverHappen("The deprecated " + "beginExecution" + " was called");
136-
}
137-
138119
@Override
139120
public InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state) {
140121
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginExecution(parameters, specificState));
141122
}
142123

143-
@Override
144-
@NotNull
145-
public InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters) {
146-
return Assert.assertShouldNeverHappen("The deprecated " + "beginParse" + " was called");
147-
}
148124

149125
@Override
150126
public InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state) {
151127
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginParse(parameters, specificState));
152128
}
153129

154-
@Override
155-
@NotNull
156-
public InstrumentationContext<List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters) {
157-
return Assert.assertShouldNeverHappen("The deprecated " + "beginValidation" + " was called");
158-
}
159130

160131
@Override
161132
public InstrumentationContext<List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state) {
162133
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginValidation(parameters, specificState));
163134
}
164135

165-
@Override
166-
@NotNull
167-
public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters) {
168-
return Assert.assertShouldNeverHappen("The deprecated " + "beginExecuteOperation" + " was called");
169-
}
170-
171136
@Override
172137
public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state) {
173138
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginExecuteOperation(parameters, specificState));
174139
}
175140

176-
@Override
177-
@NotNull
178-
public ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters) {
179-
return Assert.assertShouldNeverHappen("The deprecated " + "beginExecutionStrategy" + " was called");
180-
}
181141

182142
@Override
183143
public ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state) {
@@ -211,148 +171,67 @@ public InstrumentationContext<Object> beginDeferredField(InstrumentationState in
211171
return new ChainedDeferredExecutionStrategyInstrumentationContext(chainedMapAndDropNulls(instrumentationState, Instrumentation::beginDeferredField));
212172
}
213173

214-
@Override
215-
@NotNull
216-
public InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters) {
217-
return Assert.assertShouldNeverHappen("The deprecated " + "beginSubscribedFieldEvent" + " was called");
218-
}
219174

220175
@Override
221176
public InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state) {
222177
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginSubscribedFieldEvent(parameters, specificState));
223178
}
224179

225-
@Override
226-
@NotNull
227-
public InstrumentationContext<ExecutionResult> beginField(InstrumentationFieldParameters parameters) {
228-
return Assert.assertShouldNeverHappen("The deprecated " + "beginField" + " was called");
229-
}
230-
231-
@Override
232-
public InstrumentationContext<ExecutionResult> beginField(InstrumentationFieldParameters parameters, InstrumentationState state) {
233-
return Assert.assertShouldNeverHappen("The deprecated " + "beginField" + " was called");
234-
}
235-
236180
@Override
237181
public @Nullable InstrumentationContext<Object> beginFieldExecution(InstrumentationFieldParameters parameters, InstrumentationState state) {
238182
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginFieldExecution(parameters, specificState));
239183
}
240184

241-
@Override
242-
@NotNull
243-
public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters) {
244-
return Assert.assertShouldNeverHappen("The deprecated " + "beginFieldFetch" + " was called");
245-
}
246-
247185
@Override
248186
public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state) {
249187
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginFieldFetch(parameters, specificState));
250188
}
251189

252-
253-
@Override
254-
@NotNull
255-
public InstrumentationContext<ExecutionResult> beginFieldComplete(InstrumentationFieldCompleteParameters parameters) {
256-
return Assert.assertShouldNeverHappen("The deprecated " + "beginFieldComplete" + " was called");
257-
}
258-
259-
@Override
260-
public InstrumentationContext<ExecutionResult> beginFieldComplete(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) {
261-
return Assert.assertShouldNeverHappen("The deprecated " + "beginFieldComplete" + " was called");
262-
}
263-
264190
@Override
265191
public @Nullable InstrumentationContext<Object> beginFieldCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) {
266192
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginFieldCompletion(parameters, specificState));
267193
}
268194

269195

270-
@Override
271-
@NotNull
272-
public InstrumentationContext<ExecutionResult> beginFieldListComplete(InstrumentationFieldCompleteParameters parameters) {
273-
return Assert.assertShouldNeverHappen("The deprecated " + "beginFieldListComplete" + " was called");
274-
}
275-
276-
@Override
277-
public InstrumentationContext<ExecutionResult> beginFieldListComplete(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) {
278-
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginFieldListComplete(parameters, specificState));
279-
}
280-
281196
@Override
282197
public @Nullable InstrumentationContext<Object> beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) {
283198
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginFieldListCompletion(parameters, specificState));
284199
}
285200

286-
@Override
287-
@NotNull
288-
public ExecutionInput instrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters) {
289-
return Assert.assertShouldNeverHappen("The deprecated " + "instrumentExecutionInput" + " was called");
290-
}
291-
292201
@NotNull
293202
@Override
294203
public ExecutionInput instrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters, InstrumentationState state) {
295204
return chainedInstrument(state, executionInput, (instrumentation, specificState, accumulator) -> instrumentation.instrumentExecutionInput(accumulator, parameters, specificState));
296205
}
297206

298-
@Override
299-
@NotNull
300-
public DocumentAndVariables instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters) {
301-
return Assert.assertShouldNeverHappen("The deprecated " + "instrumentDocumentAndVariables" + " was called");
302-
}
303-
304207
@NotNull
305208
@Override
306209
public DocumentAndVariables instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters, InstrumentationState state) {
307210
return chainedInstrument(state, documentAndVariables, (instrumentation, specificState, accumulator) ->
308211
instrumentation.instrumentDocumentAndVariables(accumulator, parameters, specificState));
309212
}
310213

311-
@Override
312-
@NotNull
313-
public GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters) {
314-
return Assert.assertShouldNeverHappen("The deprecated " + "instrumentSchema" + " was called");
315-
}
316-
317214
@NotNull
318215
@Override
319216
public GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters, InstrumentationState state) {
320217
return chainedInstrument(state, schema, (instrumentation, specificState, accumulator) ->
321218
instrumentation.instrumentSchema(accumulator, parameters, specificState));
322219
}
323220

324-
@Override
325-
@NotNull
326-
public ExecutionContext instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters) {
327-
return Assert.assertShouldNeverHappen("The deprecated " + "instrumentExecutionContext" + " was called");
328-
}
329-
330221
@NotNull
331222
@Override
332223
public ExecutionContext instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters, InstrumentationState state) {
333224
return chainedInstrument(state, executionContext, (instrumentation, specificState, accumulator) ->
334225
instrumentation.instrumentExecutionContext(accumulator, parameters, specificState));
335226
}
336227

337-
@Override
338-
@NotNull
339-
public DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters) {
340-
return Assert.assertShouldNeverHappen("The deprecated " + "instrumentDataFetcher" + " was called");
341-
}
342-
343228
@NotNull
344229
@Override
345230
public DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state) {
346231
return chainedInstrument(state, dataFetcher, (Instrumentation instrumentation, InstrumentationState specificState, DataFetcher<?> accumulator) ->
347232
instrumentation.instrumentDataFetcher(accumulator, parameters, specificState));
348233
}
349234

350-
@Override
351-
@NotNull
352-
public CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters) {
353-
return Assert.assertShouldNeverHappen("The deprecated " + "instrumentExecutionResult" + " was called");
354-
}
355-
356235
@NotNull
357236
@Override
358237
public CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState state) {

0 commit comments

Comments
 (0)