Skip to content

Commit cf724bf

Browse files
committed
Annotate MaxQueryDepthInstrumentation
1 parent ed2961f commit cf724bf

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

.claude/commands/jspecify-annotate.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ If you find NullAway errors, try and make the smallest possible change to fix th
2121
Finally, can you remove this class from the JSpecifyAnnotationsCheck as an exemption. Thanks
2222

2323
You do not need to run the JSpecifyAnnotationsCheck. Removing the completed class is enough.
24+
25+
Remember to delete all unused imports wehn you're done from the class you've just annotated.

src/main/java/graphql/analysis/MaxQueryDepthInstrumentation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import graphql.execution.instrumentation.InstrumentationState;
99
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
1010
import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters;
11+
import org.jspecify.annotations.NullMarked;
1112
import org.jspecify.annotations.Nullable;
1213

1314
import java.util.function.Function;
@@ -21,9 +22,9 @@
2122
* exceeded. If the function returns {@code true} a {@link AbortExecutionException} is thrown.
2223
*/
2324
@PublicApi
25+
@NullMarked
2426
public class MaxQueryDepthInstrumentation extends SimplePerformantInstrumentation {
2527

26-
2728
private final int maxDepth;
2829
private final Function<QueryDepthInfo, Boolean> maxQueryDepthExceededFunction;
2930

@@ -48,7 +49,7 @@ public MaxQueryDepthInstrumentation(int maxDepth, Function<QueryDepthInfo, Boole
4849
}
4950

5051
@Override
51-
public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state) {
52+
public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state) {
5253
QueryTraverser queryTraverser = newQueryTraverser(parameters.getExecutionContext());
5354
int depth = queryTraverser.reducePreOrder((env, acc) -> Math.max(getPathLength(env.getParentEnvironment()), acc), 0);
5455
if (depth > maxDepth) {
@@ -84,7 +85,7 @@ QueryTraverser newQueryTraverser(ExecutionContext executionContext) {
8485
.build();
8586
}
8687

87-
private int getPathLength(QueryVisitorFieldEnvironment path) {
88+
private int getPathLength(@Nullable QueryVisitorFieldEnvironment path) {
8889
int length = 1;
8990
while (path != null) {
9091
path = path.getParentEnvironment();

src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import spock.lang.Specification
1111
class JSpecifyAnnotationsCheck extends Specification {
1212

1313
private static final Set<String> JSPECIFY_EXEMPTION_LIST = [
14-
"graphql.analysis.MaxQueryDepthInstrumentation",
1514
"graphql.analysis.QueryComplexityCalculator",
1615
"graphql.analysis.QueryComplexityInfo",
1716
"graphql.analysis.QueryDepthInfo",

0 commit comments

Comments
 (0)