Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
#4182 - code built schemas should perform deprecated non null field v…
…alidations as well as SDL built ones
  • Loading branch information
bbakerman committed Dec 18, 2025
commit dd5bc0309af8d8902de59b4a487bfbd9a0c34f63
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public TraversalControl visitGraphQLInputObjectField(GraphQLInputObjectField inp
// An applied directive's argument cannot be deprecated.
@Override
public TraversalControl visitGraphQLArgument(GraphQLArgument argument, TraverserContext<GraphQLSchemaElement> context) {
boolean isDeprecated = isDeprecated(argument);
// even if an argument is built using SLD or direct via code, the isDeprecated() method works
boolean isDeprecated = argument.isDeprecated();
if (isDeprecated && GraphQLTypeUtil.isNonNull(argument.getType()) && !argument.hasSetDefaultValue()) {
if (context.getParentNode() instanceof GraphQLFieldDefinition) {
GraphQLFieldDefinition fieldDefinition = (GraphQLFieldDefinition) context.getParentNode();
Expand All @@ -59,14 +60,4 @@ public TraversalControl visitGraphQLArgument(GraphQLArgument argument, Traverser
return TraversalControl.CONTINUE;
}

private boolean isDeprecated(GraphQLArgument argument) {
// There can only be at most one @deprecated, because it is not a repeatable directive
GraphQLAppliedDirective deprecatedDirective = argument.getAppliedDirective(Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName());
if (deprecatedDirective != null) {
return true;
}
// handle code built schemas, where they have no directive but `graphql.schema.GraphQLArgument.Builder#deprecate` has been called directly
return argument.isDeprecated();
}

}
Loading