Skip to content

Commit 4a9cd36

Browse files
committed
Clarify anonymizer directive argument lookup
1 parent 9cfdd7a commit 4a9cd36

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/graphql/util/Anonymizer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,16 @@ public TraversalControl visitArgument(Argument argument, TraverserContext<Node>
891891
// An argument is either from a applied query directive or from a field
892892
if (context.getVarFromParents(GraphQLDirective.class) != null) {
893893
GraphQLDirective directiveDefinition = context.getVarFromParents(GraphQLDirective.class);
894-
graphQLArgumentDefinition = directiveDefinition.getArgument(argument.getName());
894+
graphQLArgumentDefinition = assertNotNull(
895+
directiveDefinition.getArgument(argument.getName()),
896+
"Directive '%s' argument '%s' not found",
897+
directiveDefinition.getName(),
898+
argument.getName());
895899
} else {
896900
GraphQLFieldDefinition graphQLFieldDefinition = assertNotNull(context.getVarFromParents(GraphQLFieldDefinition.class));
897901
graphQLArgumentDefinition = graphQLFieldDefinition.getArgument(argument.getName());
898902
}
899-
GraphQLInputType argumentType = assertNotNull(graphQLArgumentDefinition).getType();
903+
GraphQLInputType argumentType = graphQLArgumentDefinition.getType();
900904
String newName = assertNotNull(astNodeToNewName.get(argument));
901905
Value newValue = replaceValue(argument.getValue(), argumentType, newNames, defaultStringValueCounter, defaultIntValueCounter);
902906
return changeNode(context, argument.transform(builder -> builder.name(newName).value(newValue)));

0 commit comments

Comments
 (0)