Skip to content

Commit 55e7a2d

Browse files
committed
introspection: expose fields/values with empty deprecationReason
1 parent a6c50de commit 55e7a2d

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

src/type/__tests__/introspection-test.js

+21-26
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,10 @@ describe('Introspection', () => {
10001000
type: GraphQLString,
10011001
deprecationReason: 'Removed in 1.0',
10021002
},
1003+
deprecatedWithEmptyReason: {
1004+
type: GraphQLString,
1005+
deprecationReason: '',
1006+
},
10031007
},
10041008
});
10051009

@@ -1032,6 +1036,11 @@ describe('Introspection', () => {
10321036
isDeprecated: true,
10331037
deprecationReason: 'Removed in 1.0',
10341038
},
1039+
{
1040+
name: 'deprecatedWithEmptyReason',
1041+
isDeprecated: true,
1042+
deprecationReason: '',
1043+
},
10351044
],
10361045
},
10371046
},
@@ -1160,9 +1169,10 @@ describe('Introspection', () => {
11601169
const TestEnum = new GraphQLEnumType({
11611170
name: 'TestEnum',
11621171
values: {
1163-
NON_DEPRECATED: { value: 0 },
1164-
DEPRECATED: { value: 1, deprecationReason: 'Removed in 1.0' },
1165-
ALSO_NON_DEPRECATED: { value: 2 },
1172+
NON_DEPRECATED: {},
1173+
DEPRECATED: { deprecationReason: 'Removed in 1.0' },
1174+
DEPRECATED_WITH_EMPTY_REASON: { deprecationReason: '' },
1175+
ALSO_NON_DEPRECATED: {},
11661176
},
11671177
});
11681178

@@ -1179,7 +1189,6 @@ describe('Introspection', () => {
11791189
const source = `
11801190
{
11811191
__type(name: "TestEnum") {
1182-
name
11831192
trueValues: enumValues(includeDeprecated: true) {
11841193
name
11851194
}
@@ -1196,33 +1205,19 @@ describe('Introspection', () => {
11961205
expect(graphqlSync({ schema, source })).to.deep.equal({
11971206
data: {
11981207
__type: {
1199-
name: 'TestEnum',
12001208
trueValues: [
1201-
{
1202-
name: 'NON_DEPRECATED',
1203-
},
1204-
{
1205-
name: 'DEPRECATED',
1206-
},
1207-
{
1208-
name: 'ALSO_NON_DEPRECATED',
1209-
},
1209+
{ name: 'NON_DEPRECATED' },
1210+
{ name: 'DEPRECATED' },
1211+
{ name: 'DEPRECATED_WITH_EMPTY_REASON' },
1212+
{ name: 'ALSO_NON_DEPRECATED' },
12101213
],
12111214
falseValues: [
1212-
{
1213-
name: 'NON_DEPRECATED',
1214-
},
1215-
{
1216-
name: 'ALSO_NON_DEPRECATED',
1217-
},
1215+
{ name: 'NON_DEPRECATED' },
1216+
{ name: 'ALSO_NON_DEPRECATED' },
12181217
],
12191218
omittedValues: [
1220-
{
1221-
name: 'NON_DEPRECATED',
1222-
},
1223-
{
1224-
name: 'ALSO_NON_DEPRECATED',
1225-
},
1219+
{ name: 'NON_DEPRECATED' },
1220+
{ name: 'ALSO_NON_DEPRECATED' },
12261221
],
12271222
},
12281223
},

src/type/introspection.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export const __Type = new GraphQLObjectType({
237237
if (isObjectType(type) || isInterfaceType(type)) {
238238
let fields = objectValues(type.getFields());
239239
if (!includeDeprecated) {
240-
fields = fields.filter(field => !field.deprecationReason);
240+
fields = fields.filter(field => !field.isDeprecated);
241241
}
242242
return fields;
243243
}
@@ -269,7 +269,7 @@ export const __Type = new GraphQLObjectType({
269269
if (isEnumType(type)) {
270270
let values = type.getValues();
271271
if (!includeDeprecated) {
272-
values = values.filter(value => !value.deprecationReason);
272+
values = values.filter(value => !value.isDeprecated);
273273
}
274274
return values;
275275
}

0 commit comments

Comments
 (0)