Skip to content

Commit 3e2e2cc

Browse files
Remove deprecated {GraphQLEnumValue, GraphQLField}::isDeprecated (#2902)
1 parent ec2352a commit 3e2e2cc

File tree

8 files changed

+1
-77
lines changed

8 files changed

+1
-77
lines changed

src/type/__tests__/definition-test.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,11 @@ describe('Type System: Objects', () => {
225225

226226
expect(TypeWithDeprecatedField.getFields().bar).to.include({
227227
name: 'bar',
228-
isDeprecated: true,
229228
deprecationReason: 'A terrible reason',
230229
});
231230

232231
expect(TypeWithDeprecatedField.getFields().baz).to.include({
233232
name: 'baz',
234-
isDeprecated: true,
235233
deprecationReason: '',
236234
});
237235
});
@@ -251,7 +249,6 @@ describe('Type System: Objects', () => {
251249
args: [],
252250
resolve: undefined,
253251
subscribe: undefined,
254-
isDeprecated: false,
255252
deprecationReason: undefined,
256253
extensions: undefined,
257254
astNode: undefined,
@@ -289,7 +286,6 @@ describe('Type System: Objects', () => {
289286
],
290287
resolve: undefined,
291288
subscribe: undefined,
292-
isDeprecated: false,
293289
deprecationReason: undefined,
294290
extensions: undefined,
295291
astNode: undefined,
@@ -384,20 +380,6 @@ describe('Type System: Objects', () => {
384380
);
385381
});
386382

387-
it('rejects an Object type with an isDeprecated instead of deprecationReason on field', () => {
388-
const OldObject = new GraphQLObjectType({
389-
name: 'OldObject',
390-
// $FlowExpectedError[incompatible-call]
391-
fields: {
392-
field: { type: ScalarType, isDeprecated: true },
393-
},
394-
});
395-
396-
expect(() => OldObject.getFields()).to.throw(
397-
'OldObject.field should provide "deprecationReason" instead of "isDeprecated".',
398-
);
399-
});
400-
401383
it('rejects an Object type with incorrectly typed interfaces', () => {
402384
const objType = new GraphQLObjectType({
403385
name: 'SomeObject',
@@ -621,13 +603,11 @@ describe('Type System: Enums', () => {
621603

622604
expect(EnumTypeWithDeprecatedValue.getValues()[0]).to.include({
623605
name: 'foo',
624-
isDeprecated: true,
625606
deprecationReason: 'Just because',
626607
});
627608

628609
expect(EnumTypeWithDeprecatedValue.getValues()[1]).to.include({
629610
name: 'bar',
630-
isDeprecated: true,
631611
deprecationReason: '',
632612
});
633613
});
@@ -647,7 +627,6 @@ describe('Type System: Enums', () => {
647627
name: 'NULL',
648628
description: undefined,
649629
value: null,
650-
isDeprecated: false,
651630
deprecationReason: undefined,
652631
extensions: undefined,
653632
astNode: undefined,
@@ -656,7 +635,6 @@ describe('Type System: Enums', () => {
656635
name: 'NAN',
657636
description: undefined,
658637
value: NaN,
659-
isDeprecated: false,
660638
deprecationReason: undefined,
661639
extensions: undefined,
662640
astNode: undefined,
@@ -665,7 +643,6 @@ describe('Type System: Enums', () => {
665643
name: 'NO_CUSTOM_VALUE',
666644
description: undefined,
667645
value: 'NO_CUSTOM_VALUE',
668-
isDeprecated: false,
669646
deprecationReason: undefined,
670647
extensions: undefined,
671648
astNode: undefined,
@@ -740,21 +717,6 @@ describe('Type System: Enums', () => {
740717
'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: 10.',
741718
);
742719
});
743-
744-
it('does not allow isDeprecated instead of deprecationReason on enum', () => {
745-
expect(
746-
() =>
747-
new GraphQLEnumType({
748-
name: 'SomeEnum',
749-
// $FlowExpectedError[prop-missing]
750-
values: {
751-
FOO: { isDeprecated: true },
752-
},
753-
}),
754-
).to.throw(
755-
'SomeEnum.FOO should provide "deprecationReason" instead of "isDeprecated".',
756-
);
757-
});
758720
});
759721

760722
describe('Type System: Input Objects', () => {

src/type/__tests__/enumType-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ describe('Type System: Enum Values', () => {
345345
name: 'ONE',
346346
description: undefined,
347347
value: Complex1,
348-
isDeprecated: false,
349348
deprecationReason: undefined,
350349
extensions: undefined,
351350
astNode: undefined,
@@ -354,7 +353,6 @@ describe('Type System: Enum Values', () => {
354353
name: 'TWO',
355354
description: undefined,
356355
value: Complex2,
357-
isDeprecated: false,
358356
deprecationReason: undefined,
359357
extensions: undefined,
360358
astNode: undefined,

src/type/definition.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,6 @@ export interface GraphQLField<
569569
deprecationReason: Maybe<string>;
570570
extensions: Maybe<Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>>;
571571
astNode?: Maybe<FieldDefinitionNode>;
572-
573-
// @deprecated and will be removed in v16
574-
isDeprecated: boolean;
575572
}
576573

577574
export interface GraphQLArgument {
@@ -836,9 +833,6 @@ export interface GraphQLEnumValue {
836833
deprecationReason: Maybe<string>;
837834
extensions: Maybe<Readonly<GraphQLEnumValueExtensions>>;
838835
astNode?: Maybe<EnumValueDefinitionNode>;
839-
840-
// @deprecated and will be removed in v16
841-
isDeprecated: boolean;
842836
}
843837

844838
/**

src/type/definition.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,6 @@ function defineFieldMap<TSource, TContext>(
829829
isPlainObj(fieldConfig),
830830
`${config.name}.${fieldName} field config must be an object.`,
831831
);
832-
devAssert(
833-
!('isDeprecated' in fieldConfig),
834-
`${config.name}.${fieldName} should provide "deprecationReason" instead of "isDeprecated".`,
835-
);
836832
devAssert(
837833
fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function',
838834
`${config.name}.${fieldName} field resolver must be a function if ` +
@@ -862,7 +858,6 @@ function defineFieldMap<TSource, TContext>(
862858
args,
863859
resolve: fieldConfig.resolve,
864860
subscribe: fieldConfig.subscribe,
865-
isDeprecated: fieldConfig.deprecationReason != null,
866861
deprecationReason: fieldConfig.deprecationReason,
867862
extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions),
868863
astNode: fieldConfig.astNode,
@@ -1012,9 +1007,6 @@ export type GraphQLField<
10121007
deprecationReason: ?string,
10131008
extensions: ?ReadOnlyObjMap<mixed>,
10141009
astNode: ?FieldDefinitionNode,
1015-
1016-
// @deprecated and will be removed in v16
1017-
isDeprecated: boolean,
10181010
|};
10191011

10201012
export type GraphQLArgument = {|
@@ -1441,15 +1433,10 @@ function defineEnumValues(
14411433
`${typeName}.${valueName} must refer to an object with a "value" key ` +
14421434
`representing an internal value but got: ${inspect(valueConfig)}.`,
14431435
);
1444-
devAssert(
1445-
!('isDeprecated' in valueConfig),
1446-
`${typeName}.${valueName} should provide "deprecationReason" instead of "isDeprecated".`,
1447-
);
14481436
return {
14491437
name: valueName,
14501438
description: valueConfig.description,
14511439
value: valueConfig.value !== undefined ? valueConfig.value : valueName,
1452-
isDeprecated: valueConfig.deprecationReason != null,
14531440
deprecationReason: valueConfig.deprecationReason,
14541441
extensions: valueConfig.extensions && toObjMap(valueConfig.extensions),
14551442
astNode: valueConfig.astNode,
@@ -1489,9 +1476,6 @@ export type GraphQLEnumValue /* <T> */ = {|
14891476
deprecationReason: ?string,
14901477
extensions: ?ReadOnlyObjMap<mixed>,
14911478
astNode: ?EnumValueDefinitionNode,
1492-
1493-
// @deprecated and will be removed in v16
1494-
isDeprecated: boolean,
14951479
|};
14961480

14971481
/**

src/type/introspection.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ export const SchemaMetaFieldDef: GraphQLField<mixed, mixed> = {
493493
description: 'Access the current type schema of this server.',
494494
args: [],
495495
resolve: (_source, _args, _context, { schema }) => schema,
496-
isDeprecated: false,
497496
deprecationReason: undefined,
498497
extensions: undefined,
499498
astNode: undefined,
@@ -515,7 +514,6 @@ export const TypeMetaFieldDef: GraphQLField<mixed, mixed> = {
515514
},
516515
],
517516
resolve: (_source, { name }, _context, { schema }) => schema.getType(name),
518-
isDeprecated: false,
519517
deprecationReason: undefined,
520518
extensions: undefined,
521519
astNode: undefined,
@@ -527,7 +525,6 @@ export const TypeNameMetaFieldDef: GraphQLField<mixed, mixed> = {
527525
description: 'The name of the current Object type at runtime.',
528526
args: [],
529527
resolve: (_source, _args, _context, { parentType }) => parentType.name,
530-
isDeprecated: false,
531528
deprecationReason: undefined,
532529
extensions: undefined,
533530
astNode: undefined,

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,27 +645,23 @@ describe('Schema Builder', () => {
645645
const myEnum = assertEnumType(schema.getType('MyEnum'));
646646

647647
const value = myEnum.getValue('VALUE');
648-
expect(value).to.include({ isDeprecated: false });
648+
expect(value).to.include({ deprecationReason: undefined });
649649

650650
const oldValue = myEnum.getValue('OLD_VALUE');
651651
expect(oldValue).to.include({
652-
isDeprecated: true,
653652
deprecationReason: 'No longer supported',
654653
});
655654

656655
const otherValue = myEnum.getValue('OTHER_VALUE');
657656
expect(otherValue).to.include({
658-
isDeprecated: true,
659657
deprecationReason: 'Terrible reasons',
660658
});
661659

662660
const rootFields = assertObjectType(schema.getType('Query')).getFields();
663661
expect(rootFields.field1).to.include({
664-
isDeprecated: true,
665662
deprecationReason: 'No longer supported',
666663
});
667664
expect(rootFields.field2).to.include({
668-
isDeprecated: true,
669665
deprecationReason: 'Because I said so',
670666
});
671667

src/utilities/__tests__/buildClientSchema-test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ describe('Type System: build schema from introspection', () => {
381381
name: 'VEGETABLES',
382382
description: 'Foods that are vegetables.',
383383
value: 'VEGETABLES',
384-
isDeprecated: false,
385384
deprecationReason: null,
386385
extensions: undefined,
387386
astNode: undefined,
@@ -390,7 +389,6 @@ describe('Type System: build schema from introspection', () => {
390389
name: 'FRUITS',
391390
description: null,
392391
value: 'FRUITS',
393-
isDeprecated: false,
394392
deprecationReason: null,
395393
extensions: undefined,
396394
astNode: undefined,
@@ -399,7 +397,6 @@ describe('Type System: build schema from introspection', () => {
399397
name: 'OILS',
400398
description: null,
401399
value: 'OILS',
402-
isDeprecated: true,
403400
deprecationReason: 'Too fatty',
404401
extensions: undefined,
405402
astNode: undefined,

src/utilities/__tests__/extendSchema-test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,11 @@ describe('extendSchema', () => {
530530

531531
const someType = assertObjectType(extendedSchema.getType('SomeObject'));
532532
expect(someType.getFields().deprecatedField).to.include({
533-
isDeprecated: true,
534533
deprecationReason: 'not used anymore',
535534
});
536535

537536
const someEnum = assertEnumType(extendedSchema.getType('SomeEnum'));
538537
expect(someEnum.getValue('DEPRECATED_VALUE')).to.include({
539-
isDeprecated: true,
540538
deprecationReason: 'do not use',
541539
});
542540
});
@@ -552,7 +550,6 @@ describe('extendSchema', () => {
552550

553551
const someType = assertObjectType(extendedSchema.getType('SomeObject'));
554552
expect(someType.getFields().deprecatedField).to.include({
555-
isDeprecated: true,
556553
deprecationReason: 'not used anymore',
557554
});
558555
});
@@ -568,7 +565,6 @@ describe('extendSchema', () => {
568565

569566
const someEnum = assertEnumType(extendedSchema.getType('SomeEnum'));
570567
expect(someEnum.getValue('DEPRECATED_VALUE')).to.include({
571-
isDeprecated: true,
572568
deprecationReason: 'do not use',
573569
});
574570
});

0 commit comments

Comments
 (0)