Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated {GraphQLEnumValue, GraphQLField}::isDeprecated #2902

Merged
merged 1 commit into from Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 0 additions & 38 deletions src/type/__tests__/definition-test.js
Expand Up @@ -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: '',
});
});
Expand All @@ -251,7 +249,6 @@ describe('Type System: Objects', () => {
args: [],
resolve: undefined,
subscribe: undefined,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand Down Expand Up @@ -289,7 +286,6 @@ describe('Type System: Objects', () => {
],
resolve: undefined,
subscribe: undefined,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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: '',
});
});
Expand All @@ -647,7 +627,6 @@ describe('Type System: Enums', () => {
name: 'NULL',
description: undefined,
value: null,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand All @@ -656,7 +635,6 @@ describe('Type System: Enums', () => {
name: 'NAN',
description: undefined,
value: NaN,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand All @@ -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,
Expand Down Expand Up @@ -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', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/type/__tests__/enumType-test.js
Expand Up @@ -345,7 +345,6 @@ describe('Type System: Enum Values', () => {
name: 'ONE',
description: undefined,
value: Complex1,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand All @@ -354,7 +353,6 @@ describe('Type System: Enum Values', () => {
name: 'TWO',
description: undefined,
value: Complex2,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand Down
6 changes: 0 additions & 6 deletions src/type/definition.d.ts
Expand Up @@ -569,9 +569,6 @@ export interface GraphQLField<
deprecationReason: Maybe<string>;
extensions: Maybe<Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>>;
astNode?: Maybe<FieldDefinitionNode>;

// @deprecated and will be removed in v16
isDeprecated: boolean;
}

export interface GraphQLArgument {
Expand Down Expand Up @@ -836,9 +833,6 @@ export interface GraphQLEnumValue {
deprecationReason: Maybe<string>;
extensions: Maybe<Readonly<GraphQLEnumValueExtensions>>;
astNode?: Maybe<EnumValueDefinitionNode>;

// @deprecated and will be removed in v16
isDeprecated: boolean;
}

/**
Expand Down
16 changes: 0 additions & 16 deletions src/type/definition.js
Expand Up @@ -829,10 +829,6 @@ function defineFieldMap<TSource, TContext>(
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 ` +
Expand Down Expand Up @@ -862,7 +858,6 @@ function defineFieldMap<TSource, TContext>(
args,
resolve: fieldConfig.resolve,
subscribe: fieldConfig.subscribe,
isDeprecated: fieldConfig.deprecationReason != null,
deprecationReason: fieldConfig.deprecationReason,
extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions),
astNode: fieldConfig.astNode,
Expand Down Expand Up @@ -1012,9 +1007,6 @@ export type GraphQLField<
deprecationReason: ?string,
extensions: ?ReadOnlyObjMap<mixed>,
astNode: ?FieldDefinitionNode,

// @deprecated and will be removed in v16
isDeprecated: boolean,
|};

export type GraphQLArgument = {|
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1489,9 +1476,6 @@ export type GraphQLEnumValue /* <T> */ = {|
deprecationReason: ?string,
extensions: ?ReadOnlyObjMap<mixed>,
astNode: ?EnumValueDefinitionNode,

// @deprecated and will be removed in v16
isDeprecated: boolean,
|};

/**
Expand Down
3 changes: 0 additions & 3 deletions src/type/introspection.js
Expand Up @@ -493,7 +493,6 @@ export const SchemaMetaFieldDef: GraphQLField<mixed, mixed> = {
description: 'Access the current type schema of this server.',
args: [],
resolve: (_source, _args, _context, { schema }) => schema,
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand All @@ -515,7 +514,6 @@ export const TypeMetaFieldDef: GraphQLField<mixed, mixed> = {
},
],
resolve: (_source, { name }, _context, { schema }) => schema.getType(name),
isDeprecated: false,
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand All @@ -527,7 +525,6 @@ export const TypeNameMetaFieldDef: GraphQLField<mixed, mixed> = {
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,
Expand Down
6 changes: 1 addition & 5 deletions src/utilities/__tests__/buildASTSchema-test.js
Expand Up @@ -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',
});

Expand Down
3 changes: 0 additions & 3 deletions src/utilities/__tests__/buildClientSchema-test.js
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions src/utilities/__tests__/extendSchema-test.js
Expand Up @@ -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',
});
});
Expand All @@ -552,7 +550,6 @@ describe('extendSchema', () => {

const someType = assertObjectType(extendedSchema.getType('SomeObject'));
expect(someType.getFields().deprecatedField).to.include({
isDeprecated: true,
deprecationReason: 'not used anymore',
});
});
Expand All @@ -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',
});
});
Expand Down