From cd1b4fac33e2024187e6bfa767c1dd36797ede79 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sun, 31 Jan 2021 14:31:59 +0200 Subject: [PATCH] Remove deprecated {GraphQLEnumValue, GraphQLField}::isDeprecated (#2902) --- src/type/__tests__/definition-test.js | 38 ------------------- src/type/__tests__/enumType-test.js | 2 - src/type/definition.d.ts | 6 --- src/type/definition.js | 16 -------- src/type/introspection.js | 3 -- .../__tests__/buildASTSchema-test.js | 6 +-- .../__tests__/buildClientSchema-test.js | 3 -- src/utilities/__tests__/extendSchema-test.js | 4 -- 8 files changed, 1 insertion(+), 77 deletions(-) diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index d63bc922aa3..65b176d150f 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -225,13 +225,11 @@ describe('Type System: Objects', () => { expect(TypeWithDeprecatedField.getFields().bar).to.include({ name: 'bar', - isDeprecated: true, deprecationReason: 'A terrible reason', }); expect(TypeWithDeprecatedField.getFields().baz).to.include({ name: 'baz', - isDeprecated: true, deprecationReason: '', }); }); @@ -251,7 +249,6 @@ describe('Type System: Objects', () => { args: [], resolve: undefined, subscribe: undefined, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -289,7 +286,6 @@ describe('Type System: Objects', () => { ], resolve: undefined, subscribe: undefined, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -384,20 +380,6 @@ describe('Type System: Objects', () => { ); }); - it('rejects an Object type with an isDeprecated instead of deprecationReason on field', () => { - const OldObject = new GraphQLObjectType({ - name: 'OldObject', - // $FlowExpectedError[incompatible-call] - fields: { - field: { type: ScalarType, isDeprecated: true }, - }, - }); - - expect(() => OldObject.getFields()).to.throw( - 'OldObject.field should provide "deprecationReason" instead of "isDeprecated".', - ); - }); - it('rejects an Object type with incorrectly typed interfaces', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', @@ -621,13 +603,11 @@ describe('Type System: Enums', () => { expect(EnumTypeWithDeprecatedValue.getValues()[0]).to.include({ name: 'foo', - isDeprecated: true, deprecationReason: 'Just because', }); expect(EnumTypeWithDeprecatedValue.getValues()[1]).to.include({ name: 'bar', - isDeprecated: true, deprecationReason: '', }); }); @@ -647,7 +627,6 @@ describe('Type System: Enums', () => { name: 'NULL', description: undefined, value: null, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -656,7 +635,6 @@ describe('Type System: Enums', () => { name: 'NAN', description: undefined, value: NaN, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -665,7 +643,6 @@ describe('Type System: Enums', () => { name: 'NO_CUSTOM_VALUE', description: undefined, value: 'NO_CUSTOM_VALUE', - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -740,21 +717,6 @@ describe('Type System: Enums', () => { 'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: 10.', ); }); - - it('does not allow isDeprecated instead of deprecationReason on enum', () => { - expect( - () => - new GraphQLEnumType({ - name: 'SomeEnum', - // $FlowExpectedError[prop-missing] - values: { - FOO: { isDeprecated: true }, - }, - }), - ).to.throw( - 'SomeEnum.FOO should provide "deprecationReason" instead of "isDeprecated".', - ); - }); }); describe('Type System: Input Objects', () => { diff --git a/src/type/__tests__/enumType-test.js b/src/type/__tests__/enumType-test.js index e9dbeedec23..0145657733f 100644 --- a/src/type/__tests__/enumType-test.js +++ b/src/type/__tests__/enumType-test.js @@ -345,7 +345,6 @@ describe('Type System: Enum Values', () => { name: 'ONE', description: undefined, value: Complex1, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -354,7 +353,6 @@ describe('Type System: Enum Values', () => { name: 'TWO', description: undefined, value: Complex2, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, diff --git a/src/type/definition.d.ts b/src/type/definition.d.ts index 06799981f9e..5e5edb05486 100644 --- a/src/type/definition.d.ts +++ b/src/type/definition.d.ts @@ -569,9 +569,6 @@ export interface GraphQLField< deprecationReason: Maybe; extensions: Maybe>>; astNode?: Maybe; - - // @deprecated and will be removed in v16 - isDeprecated: boolean; } export interface GraphQLArgument { @@ -836,9 +833,6 @@ export interface GraphQLEnumValue { deprecationReason: Maybe; extensions: Maybe>; astNode?: Maybe; - - // @deprecated and will be removed in v16 - isDeprecated: boolean; } /** diff --git a/src/type/definition.js b/src/type/definition.js index f8d25ac11c0..c73b77ea805 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -829,10 +829,6 @@ function defineFieldMap( isPlainObj(fieldConfig), `${config.name}.${fieldName} field config must be an object.`, ); - devAssert( - !('isDeprecated' in fieldConfig), - `${config.name}.${fieldName} should provide "deprecationReason" instead of "isDeprecated".`, - ); devAssert( fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function', `${config.name}.${fieldName} field resolver must be a function if ` + @@ -862,7 +858,6 @@ function defineFieldMap( args, resolve: fieldConfig.resolve, subscribe: fieldConfig.subscribe, - isDeprecated: fieldConfig.deprecationReason != null, deprecationReason: fieldConfig.deprecationReason, extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions), astNode: fieldConfig.astNode, @@ -1012,9 +1007,6 @@ export type GraphQLField< deprecationReason: ?string, extensions: ?ReadOnlyObjMap, astNode: ?FieldDefinitionNode, - - // @deprecated and will be removed in v16 - isDeprecated: boolean, |}; export type GraphQLArgument = {| @@ -1441,15 +1433,10 @@ function defineEnumValues( `${typeName}.${valueName} must refer to an object with a "value" key ` + `representing an internal value but got: ${inspect(valueConfig)}.`, ); - devAssert( - !('isDeprecated' in valueConfig), - `${typeName}.${valueName} should provide "deprecationReason" instead of "isDeprecated".`, - ); return { name: valueName, description: valueConfig.description, value: valueConfig.value !== undefined ? valueConfig.value : valueName, - isDeprecated: valueConfig.deprecationReason != null, deprecationReason: valueConfig.deprecationReason, extensions: valueConfig.extensions && toObjMap(valueConfig.extensions), astNode: valueConfig.astNode, @@ -1489,9 +1476,6 @@ export type GraphQLEnumValue /* */ = {| deprecationReason: ?string, extensions: ?ReadOnlyObjMap, astNode: ?EnumValueDefinitionNode, - - // @deprecated and will be removed in v16 - isDeprecated: boolean, |}; /** diff --git a/src/type/introspection.js b/src/type/introspection.js index 77362ed02db..4963bd96746 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -493,7 +493,6 @@ export const SchemaMetaFieldDef: GraphQLField = { description: 'Access the current type schema of this server.', args: [], resolve: (_source, _args, _context, { schema }) => schema, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -515,7 +514,6 @@ export const TypeMetaFieldDef: GraphQLField = { }, ], resolve: (_source, { name }, _context, { schema }) => schema.getType(name), - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -527,7 +525,6 @@ export const TypeNameMetaFieldDef: GraphQLField = { description: 'The name of the current Object type at runtime.', args: [], resolve: (_source, _args, _context, { parentType }) => parentType.name, - isDeprecated: false, deprecationReason: undefined, extensions: undefined, astNode: undefined, diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index 85d0509a5cc..cb1794bd7af 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -645,27 +645,23 @@ describe('Schema Builder', () => { const myEnum = assertEnumType(schema.getType('MyEnum')); const value = myEnum.getValue('VALUE'); - expect(value).to.include({ isDeprecated: false }); + expect(value).to.include({ deprecationReason: undefined }); const oldValue = myEnum.getValue('OLD_VALUE'); expect(oldValue).to.include({ - isDeprecated: true, deprecationReason: 'No longer supported', }); const otherValue = myEnum.getValue('OTHER_VALUE'); expect(otherValue).to.include({ - isDeprecated: true, deprecationReason: 'Terrible reasons', }); const rootFields = assertObjectType(schema.getType('Query')).getFields(); expect(rootFields.field1).to.include({ - isDeprecated: true, deprecationReason: 'No longer supported', }); expect(rootFields.field2).to.include({ - isDeprecated: true, deprecationReason: 'Because I said so', }); diff --git a/src/utilities/__tests__/buildClientSchema-test.js b/src/utilities/__tests__/buildClientSchema-test.js index 33a4fe3a616..b43dca09b32 100644 --- a/src/utilities/__tests__/buildClientSchema-test.js +++ b/src/utilities/__tests__/buildClientSchema-test.js @@ -381,7 +381,6 @@ describe('Type System: build schema from introspection', () => { name: 'VEGETABLES', description: 'Foods that are vegetables.', value: 'VEGETABLES', - isDeprecated: false, deprecationReason: null, extensions: undefined, astNode: undefined, @@ -390,7 +389,6 @@ describe('Type System: build schema from introspection', () => { name: 'FRUITS', description: null, value: 'FRUITS', - isDeprecated: false, deprecationReason: null, extensions: undefined, astNode: undefined, @@ -399,7 +397,6 @@ describe('Type System: build schema from introspection', () => { name: 'OILS', description: null, value: 'OILS', - isDeprecated: true, deprecationReason: 'Too fatty', extensions: undefined, astNode: undefined, diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index 094713a507a..64ac885c4bd 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -530,13 +530,11 @@ describe('extendSchema', () => { const someType = assertObjectType(extendedSchema.getType('SomeObject')); expect(someType.getFields().deprecatedField).to.include({ - isDeprecated: true, deprecationReason: 'not used anymore', }); const someEnum = assertEnumType(extendedSchema.getType('SomeEnum')); expect(someEnum.getValue('DEPRECATED_VALUE')).to.include({ - isDeprecated: true, deprecationReason: 'do not use', }); }); @@ -552,7 +550,6 @@ describe('extendSchema', () => { const someType = assertObjectType(extendedSchema.getType('SomeObject')); expect(someType.getFields().deprecatedField).to.include({ - isDeprecated: true, deprecationReason: 'not used anymore', }); }); @@ -568,7 +565,6 @@ describe('extendSchema', () => { const someEnum = assertEnumType(extendedSchema.getType('SomeEnum')); expect(someEnum.getValue('DEPRECATED_VALUE')).to.include({ - isDeprecated: true, deprecationReason: 'do not use', }); });