1515import graphql .language .Node ;
1616import graphql .language .ObjectTypeDefinition ;
1717import graphql .language .ObjectTypeExtensionDefinition ;
18- import graphql .language .StringValue ;
1918import graphql .language .Type ;
2019import graphql .language .TypeDefinition ;
2120import graphql .language .TypeName ;
2221import graphql .language .UnionTypeDefinition ;
2322import graphql .schema .idl .errors .DirectiveIllegalLocationError ;
24- import graphql .schema .idl .errors .InvalidDeprecationDirectiveError ;
2523import graphql .schema .idl .errors .MissingInterfaceTypeError ;
2624import graphql .schema .idl .errors .MissingScalarImplementationError ;
2725import graphql .schema .idl .errors .MissingTypeError ;
4341import java .util .function .Consumer ;
4442import java .util .function .Function ;
4543import java .util .function .Predicate ;
46- import java .util .function .Supplier ;
4744
45+ import static graphql .introspection .Introspection .DirectiveLocation .INPUT_FIELD_DEFINITION ;
4846import static java .util .stream .Collectors .toList ;
4947
5048/**
@@ -198,7 +196,7 @@ private void checkFieldsAreSensible(List<GraphQLError> errors, TypeDefinitionReg
198196
199197 // input types
200198 List <InputObjectTypeDefinition > inputTypes = filterTo (typesMap , InputObjectTypeDefinition .class );
201- inputTypes .forEach (inputType -> checkInputValues (errors , inputType , inputType .getInputValueDefinitions ()));
199+ inputTypes .forEach (inputType -> checkInputValues (errors , inputType , inputType .getInputValueDefinitions (), INPUT_FIELD_DEFINITION ));
202200 }
203201
204202
@@ -216,8 +214,6 @@ private void checkObjTypeFields(List<GraphQLError> errors, ObjectTypeDefinition
216214 (directiveName , directive ) -> new NonUniqueDirectiveError (typeDefinition , fld , directiveName )));
217215
218216 fieldDefinitions .forEach (fld -> fld .getDirectives ().forEach (directive -> {
219- checkDeprecatedDirective (errors , directive ,
220- () -> new InvalidDeprecationDirectiveError (typeDefinition , fld ));
221217
222218 checkNamedUniqueness (errors , directive .getArguments (), Argument ::getName ,
223219 (argumentName , argument ) -> new NonUniqueArgumentError (typeDefinition , fld , argumentName ));
@@ -238,14 +234,9 @@ private void checkInterfaceFields(List<GraphQLError> errors, InterfaceTypeDefini
238234 fieldDefinitions .forEach (fld -> checkNamedUniqueness (errors , fld .getDirectives (), Directive ::getName ,
239235 (directiveName , directive ) -> new NonUniqueDirectiveError (interfaceType , fld , directiveName )));
240236
241- fieldDefinitions .forEach (fld -> fld .getDirectives ().forEach (directive -> {
242- checkDeprecatedDirective (errors , directive ,
243- () -> new InvalidDeprecationDirectiveError (interfaceType , fld ));
244-
245- checkNamedUniqueness (errors , directive .getArguments (), Argument ::getName ,
246- (argumentName , argument ) -> new NonUniqueArgumentError (interfaceType , fld , argumentName ));
247-
248- }));
237+ fieldDefinitions .forEach (fld -> fld .getDirectives ().forEach (directive ->
238+ checkNamedUniqueness (errors , directive .getArguments (), Argument ::getName ,
239+ (argumentName , argument ) -> new NonUniqueArgumentError (interfaceType , fld , argumentName ))));
249240 }
250241
251242 private void checkEnumValues (List <GraphQLError > errors , EnumTypeDefinition enumType , List <EnumValueDefinition > enumValueDefinitions ) {
@@ -262,16 +253,14 @@ private void checkEnumValues(List<GraphQLError> errors, EnumTypeDefinition enumT
262253 });
263254
264255 enumValueDefinitions .forEach (enumValue -> enumValue .getDirectives ().forEach (directive -> {
265- checkDeprecatedDirective (errors , directive ,
266- () -> new InvalidDeprecationDirectiveError (enumType , enumValue ));
267256
268257 BiFunction <String , Argument , NonUniqueArgumentError > errorFunction = (argumentName , argument ) -> new NonUniqueArgumentError (enumType , enumValue , argumentName );
269258 checkNamedUniqueness (errors , directive .getArguments (), Argument ::getName , errorFunction );
270259
271260 }));
272261 }
273262
274- private void checkInputValues (List <GraphQLError > errors , InputObjectTypeDefinition inputType , List <InputValueDefinition > inputValueDefinitions ) {
263+ private void checkInputValues (List <GraphQLError > errors , InputObjectTypeDefinition inputType , List <InputValueDefinition > inputValueDefinitions , Introspection . DirectiveLocation directiveLocation ) {
275264
276265 // field unique ness
277266 checkNamedUniqueness (errors , inputValueDefinitions , InputValueDefinition ::getName ,
@@ -287,40 +276,9 @@ private void checkInputValues(List<GraphQLError> errors, InputObjectTypeDefiniti
287276 inputValueDefinitions .forEach (inputValueDef -> checkNamedUniqueness (errors , inputValueDef .getDirectives (), Directive ::getName ,
288277 (directiveName , directive ) -> new NonUniqueDirectiveError (inputType , inputValueDef , directiveName )));
289278
290- inputValueDefinitions .forEach (inputValueDef -> inputValueDef .getDirectives ().forEach (directive -> {
291- checkDeprecatedDirective (errors , directive ,
292- () -> new InvalidDeprecationDirectiveError (inputType , inputValueDef ));
293-
294- checkNamedUniqueness (errors , directive .getArguments (), Argument ::getName ,
295- (argumentName , argument ) -> new NonUniqueArgumentError (inputType , inputValueDef , argumentName ));
296- }));
297- }
298-
299-
300- /**
301- * A special check for the magic @deprecated directive
302- *
303- * @param errors the list of errors
304- * @param directive the directive to check
305- * @param errorSupplier the error supplier function
306- */
307- static void checkDeprecatedDirective (List <GraphQLError > errors , Directive directive , Supplier <InvalidDeprecationDirectiveError > errorSupplier ) {
308- if ("deprecated" .equals (directive .getName ())) {
309- // it can have zero args
310- List <Argument > arguments = directive .getArguments ();
311- if (arguments .size () == 0 ) {
312- return ;
313- }
314- // but if has more than it must have 1 called "reason" of type StringValue
315- if (arguments .size () == 1 ) {
316- Argument arg = arguments .get (0 );
317- if ("reason" .equals (arg .getName ()) && arg .getValue () instanceof StringValue ) {
318- return ;
319- }
320- }
321- // not valid
322- errors .add (errorSupplier .get ());
323- }
279+ inputValueDefinitions .forEach (inputValueDef -> inputValueDef .getDirectives ().forEach (directive ->
280+ checkNamedUniqueness (errors , directive .getArguments (), Argument ::getName ,
281+ (argumentName , argument ) -> new NonUniqueArgumentError (inputType , inputValueDef , argumentName ))));
324282 }
325283
326284 /**
0 commit comments