@@ -42,10 +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- // There can only be at most one @deprecated, because it is not a repeatable directive
46- GraphQLAppliedDirective deprecatedDirective = argument .getAppliedDirective (Directives .DEPRECATED_DIRECTIVE_DEFINITION .getName ());
47-
48- if (deprecatedDirective != null && GraphQLTypeUtil .isNonNull (argument .getType ()) && !argument .hasSetDefaultValue ()) {
45+ boolean isDeprecated = isDeprecated (argument );
46+ if (isDeprecated && GraphQLTypeUtil .isNonNull (argument .getType ()) && !argument .hasSetDefaultValue ()) {
4947 if (context .getParentNode () instanceof GraphQLFieldDefinition ) {
5048 GraphQLFieldDefinition fieldDefinition = (GraphQLFieldDefinition ) context .getParentNode ();
5149 SchemaValidationErrorCollector errorCollector = context .getVarFromParents (SchemaValidationErrorCollector .class );
@@ -61,4 +59,14 @@ public TraversalControl visitGraphQLArgument(GraphQLArgument argument, Traverser
6159 return TraversalControl .CONTINUE ;
6260 }
6361
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+
6472}
0 commit comments