@@ -332,7 +332,17 @@ describe('Introspection', () => {
332332 } ,
333333 {
334334 name : 'inputFields' ,
335- args : [ ] ,
335+ args : [
336+ {
337+ name : 'includeDeprecated' ,
338+ type : {
339+ kind : 'SCALAR' ,
340+ name : 'Boolean' ,
341+ ofType : null ,
342+ } ,
343+ defaultValue : 'false' ,
344+ } ,
345+ ] ,
336346 type : {
337347 kind : 'LIST' ,
338348 name : null ,
@@ -450,7 +460,17 @@ describe('Introspection', () => {
450460 } ,
451461 {
452462 name : 'args' ,
453- args : [ ] ,
463+ args : [
464+ {
465+ name : 'includeDeprecated' ,
466+ type : {
467+ kind : 'SCALAR' ,
468+ name : 'Boolean' ,
469+ ofType : null ,
470+ } ,
471+ defaultValue : 'false' ,
472+ } ,
473+ ] ,
454474 type : {
455475 kind : 'NON_NULL' ,
456476 name : null ,
@@ -575,6 +595,32 @@ describe('Introspection', () => {
575595 isDeprecated : false ,
576596 deprecationReason : null ,
577597 } ,
598+ {
599+ name : 'isDeprecated' ,
600+ args : [ ] ,
601+ type : {
602+ kind : 'NON_NULL' ,
603+ name : null ,
604+ ofType : {
605+ kind : 'SCALAR' ,
606+ name : 'Boolean' ,
607+ ofType : null ,
608+ } ,
609+ } ,
610+ isDeprecated : false ,
611+ deprecationReason : null ,
612+ } ,
613+ {
614+ name : 'deprecationReason' ,
615+ args : [ ] ,
616+ type : {
617+ kind : 'SCALAR' ,
618+ name : 'String' ,
619+ ofType : null ,
620+ } ,
621+ isDeprecated : false ,
622+ deprecationReason : null ,
623+ } ,
578624 ] ,
579625 inputFields : null ,
580626 interfaces : [ ] ,
@@ -893,7 +939,12 @@ describe('Introspection', () => {
893939 {
894940 name : 'deprecated' ,
895941 isRepeatable : false ,
896- locations : [ 'FIELD_DEFINITION' , 'ENUM_VALUE' ] ,
942+ locations : [
943+ 'FIELD_DEFINITION' ,
944+ 'ARGUMENT_DEFINITION' ,
945+ 'INPUT_FIELD_DEFINITION' ,
946+ 'ENUM_VALUE' ,
947+ ] ,
897948 args : [
898949 {
899950 defaultValue : '"No longer supported"' ,
@@ -1122,6 +1173,103 @@ describe('Introspection', () => {
11221173 } ) ;
11231174 } ) ;
11241175
1176+ it ( 'identifies deprecated args' , ( ) => {
1177+ const schema = buildSchema ( `
1178+ type Query {
1179+ someField(
1180+ nonDeprecated: String
1181+ deprecated: String @deprecated(reason: "Removed in 1.0")
1182+ deprecatedWithEmptyReason: String @deprecated(reason: "")
1183+ ): String
1184+ }
1185+ ` ) ;
1186+
1187+ const source = `
1188+ {
1189+ __type(name: "Query") {
1190+ fields {
1191+ args(includeDeprecated: true) {
1192+ name
1193+ isDeprecated,
1194+ deprecationReason
1195+ }
1196+ }
1197+ }
1198+ }
1199+ ` ;
1200+
1201+ expect ( graphqlSync ( { schema, source } ) ) . to . deep . equal ( {
1202+ data : {
1203+ __type : {
1204+ fields : [
1205+ {
1206+ args : [
1207+ {
1208+ name : 'nonDeprecated' ,
1209+ isDeprecated : false ,
1210+ deprecationReason : null ,
1211+ } ,
1212+ {
1213+ name : 'deprecated' ,
1214+ isDeprecated : true ,
1215+ deprecationReason : 'Removed in 1.0' ,
1216+ } ,
1217+ {
1218+ name : 'deprecatedWithEmptyReason' ,
1219+ isDeprecated : true ,
1220+ deprecationReason : '' ,
1221+ } ,
1222+ ] ,
1223+ } ,
1224+ ] ,
1225+ } ,
1226+ } ,
1227+ } ) ;
1228+ } ) ;
1229+
1230+ it ( 'respects the includeDeprecated parameter for args' , ( ) => {
1231+ const schema = buildSchema ( `
1232+ type Query {
1233+ someField(
1234+ nonDeprecated: String
1235+ deprecated: String @deprecated(reason: "Removed in 1.0")
1236+ ): String
1237+ }
1238+ ` ) ;
1239+
1240+ const source = `
1241+ {
1242+ __type(name: "Query") {
1243+ fields {
1244+ trueArgs: args(includeDeprecated: true) {
1245+ name
1246+ }
1247+ falseArgs: args(includeDeprecated: false) {
1248+ name
1249+ }
1250+ omittedArgs: args {
1251+ name
1252+ }
1253+ }
1254+ }
1255+ }
1256+ ` ;
1257+
1258+ expect ( graphqlSync ( { schema, source } ) ) . to . deep . equal ( {
1259+ data : {
1260+ __type : {
1261+ fields : [
1262+ {
1263+ trueArgs : [ { name : 'nonDeprecated' } , { name : 'deprecated' } ] ,
1264+ falseArgs : [ { name : 'nonDeprecated' } ] ,
1265+ omittedArgs : [ { name : 'nonDeprecated' } ] ,
1266+ } ,
1267+ ] ,
1268+ } ,
1269+ } ,
1270+ } ) ;
1271+ } ) ;
1272+
11251273 it ( 'identifies deprecated enum values' , ( ) => {
11261274 const schema = buildSchema ( `
11271275 enum SomeEnum {
@@ -1224,6 +1372,95 @@ describe('Introspection', () => {
12241372 } ) ;
12251373 } ) ;
12261374
1375+ it ( 'identifies deprecated for input fields' , ( ) => {
1376+ const schema = buildSchema ( `
1377+ input SomeInputObject {
1378+ nonDeprecated: String
1379+ deprecated: String @deprecated(reason: "Removed in 1.0")
1380+ deprecatedWithEmptyReason: String @deprecated(reason: "")
1381+ }
1382+
1383+ type Query {
1384+ someField(someArg: SomeInputObject): String
1385+ }
1386+ ` ) ;
1387+
1388+ const source = `
1389+ {
1390+ __type(name: "SomeInputObject") {
1391+ inputFields(includeDeprecated: true) {
1392+ name
1393+ isDeprecated,
1394+ deprecationReason
1395+ }
1396+ }
1397+ }
1398+ ` ;
1399+
1400+ expect ( graphqlSync ( { schema, source } ) ) . to . deep . equal ( {
1401+ data : {
1402+ __type : {
1403+ inputFields : [
1404+ {
1405+ name : 'nonDeprecated' ,
1406+ isDeprecated : false ,
1407+ deprecationReason : null ,
1408+ } ,
1409+ {
1410+ name : 'deprecated' ,
1411+ isDeprecated : true ,
1412+ deprecationReason : 'Removed in 1.0' ,
1413+ } ,
1414+ {
1415+ name : 'deprecatedWithEmptyReason' ,
1416+ isDeprecated : true ,
1417+ deprecationReason : '' ,
1418+ } ,
1419+ ] ,
1420+ } ,
1421+ } ,
1422+ } ) ;
1423+ } ) ;
1424+
1425+ it ( 'respects the includeDeprecated parameter for input fields' , ( ) => {
1426+ const schema = buildSchema ( `
1427+ input SomeInputObject {
1428+ nonDeprecated: String
1429+ deprecated: String @deprecated(reason: "Removed in 1.0")
1430+ }
1431+
1432+ type Query {
1433+ someField(someArg: SomeInputObject): String
1434+ }
1435+ ` ) ;
1436+
1437+ const source = `
1438+ {
1439+ __type(name: "SomeInputObject") {
1440+ trueFields: inputFields(includeDeprecated: true) {
1441+ name
1442+ }
1443+ falseFields: inputFields(includeDeprecated: false) {
1444+ name
1445+ }
1446+ omittedFields: inputFields {
1447+ name
1448+ }
1449+ }
1450+ }
1451+ ` ;
1452+
1453+ expect ( graphqlSync ( { schema, source } ) ) . to . deep . equal ( {
1454+ data : {
1455+ __type : {
1456+ trueFields : [ { name : 'nonDeprecated' } , { name : 'deprecated' } ] ,
1457+ falseFields : [ { name : 'nonDeprecated' } ] ,
1458+ omittedFields : [ { name : 'nonDeprecated' } ] ,
1459+ } ,
1460+ } ,
1461+ } ) ;
1462+ } ) ;
1463+
12271464 it ( 'fails as expected on the __type root field without an arg' , ( ) => {
12281465 const schema = buildSchema ( `
12291466 type Query {
0 commit comments