Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd5bc03

Browse files
committed
#4182 - code built schemas should perform deprecated non null field validations as well as SDL built ones
1 parent afbcd52 commit dd5bc03

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/main/java/graphql/schema/validation/DeprecatedInputObjectAndArgumentsAreValid.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public TraversalControl visitGraphQLInputObjectField(GraphQLInputObjectField inp
4242
// An applied directive's argument cannot be deprecated.
4343
@Override
4444
public TraversalControl visitGraphQLArgument(GraphQLArgument argument, TraverserContext<GraphQLSchemaElement> context) {
45-
boolean isDeprecated = isDeprecated(argument);
45+
// even if an argument is built using SLD or direct via code, the isDeprecated() method works
46+
boolean isDeprecated = argument.isDeprecated();
4647
if (isDeprecated && GraphQLTypeUtil.isNonNull(argument.getType()) && !argument.hasSetDefaultValue()) {
4748
if (context.getParentNode() instanceof GraphQLFieldDefinition) {
4849
GraphQLFieldDefinition fieldDefinition = (GraphQLFieldDefinition) context.getParentNode();
@@ -59,14 +60,4 @@ public TraversalControl visitGraphQLArgument(GraphQLArgument argument, Traverser
5960
return TraversalControl.CONTINUE;
6061
}
6162

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

0 commit comments

Comments
 (0)