Skip to content

Commit 4472230

Browse files
committed
Add test and support for deprecated args
1 parent 13111be commit 4472230

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,8 @@ describe('Schema Builder', () => {
736736
field1: String @deprecated
737737
field2: Int @deprecated(reason: "Because I said so")
738738
enum: MyEnum
739+
field3(oldArg: String @deprecated, arg: String): String
740+
field4(oldArg: String @deprecated(reason: "why not?"), arg: String): String
739741
}
740742
`;
741743
expect(cycleSDL(sdl)).to.equal(sdl);
@@ -790,6 +792,16 @@ describe('Schema Builder', () => {
790792
`);
791793

792794
expect(printAllASTNodes(someScalar)).to.equal(scalarSDL);
795+
expect(rootFields.field2.isDeprecated).to.equal(true);
796+
expect(rootFields.field2.deprecationReason).to.equal('Because I said so');
797+
798+
const field3OldArg = rootFields.field3.args[0];
799+
expect(field3OldArg.isDeprecated).to.equal(true);
800+
expect(field3OldArg.deprecationReason).to.equal('No longer supported');
801+
802+
const field4OldArg = rootFields.field4.args[0];
803+
expect(field4OldArg.isDeprecated).to.equal(true);
804+
expect(field4OldArg.deprecationReason).to.equal('why not?');
793805
});
794806

795807
it('Correctly extend object type', () => {

src/utilities/buildASTSchema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export class ASTDefinitionBuilder {
199199
type,
200200
description: getDescription(value, this._options),
201201
defaultValue: valueFromAST(value.defaultValue, type),
202+
deprecationReason: getDeprecationReason(value),
202203
astNode: value,
203204
};
204205
}

src/utilities/printSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function printInputValue(arg) {
294294
if (defaultAST) {
295295
argDecl += ` = ${print(defaultAST)}`;
296296
}
297-
return argDecl;
297+
return argDecl + printDeprecated(arg);
298298
}
299299

300300
function printDirective(directive, options) {

0 commit comments

Comments
 (0)