Skip to content

introspection: expose fields/values with empty deprecationReason #2339

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 21 additions & 26 deletions src/type/__tests__/introspection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,10 @@ describe('Introspection', () => {
type: GraphQLString,
deprecationReason: 'Removed in 1.0',
},
deprecatedWithEmptyReason: {
type: GraphQLString,
deprecationReason: '',
},
},
});

Expand Down Expand Up @@ -1032,6 +1036,11 @@ describe('Introspection', () => {
isDeprecated: true,
deprecationReason: 'Removed in 1.0',
},
{
name: 'deprecatedWithEmptyReason',
isDeprecated: true,
deprecationReason: '',
},
],
},
},
Expand Down Expand Up @@ -1160,9 +1169,10 @@ describe('Introspection', () => {
const TestEnum = new GraphQLEnumType({
name: 'TestEnum',
values: {
NON_DEPRECATED: { value: 0 },
DEPRECATED: { value: 1, deprecationReason: 'Removed in 1.0' },
ALSO_NON_DEPRECATED: { value: 2 },
NON_DEPRECATED: {},
DEPRECATED: { deprecationReason: 'Removed in 1.0' },
DEPRECATED_WITH_EMPTY_REASON: { deprecationReason: '' },
ALSO_NON_DEPRECATED: {},
},
});

Expand All @@ -1179,7 +1189,6 @@ describe('Introspection', () => {
const source = `
{
__type(name: "TestEnum") {
name
trueValues: enumValues(includeDeprecated: true) {
name
}
Expand All @@ -1196,33 +1205,19 @@ describe('Introspection', () => {
expect(graphqlSync({ schema, source })).to.deep.equal({
data: {
__type: {
name: 'TestEnum',
trueValues: [
{
name: 'NON_DEPRECATED',
},
{
name: 'DEPRECATED',
},
{
name: 'ALSO_NON_DEPRECATED',
},
{ name: 'NON_DEPRECATED' },
{ name: 'DEPRECATED' },
{ name: 'DEPRECATED_WITH_EMPTY_REASON' },
{ name: 'ALSO_NON_DEPRECATED' },
],
falseValues: [
{
name: 'NON_DEPRECATED',
},
{
name: 'ALSO_NON_DEPRECATED',
},
{ name: 'NON_DEPRECATED' },
{ name: 'ALSO_NON_DEPRECATED' },
],
omittedValues: [
{
name: 'NON_DEPRECATED',
},
{
name: 'ALSO_NON_DEPRECATED',
},
{ name: 'NON_DEPRECATED' },
{ name: 'ALSO_NON_DEPRECATED' },
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/type/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const __Type = new GraphQLObjectType({
if (isObjectType(type) || isInterfaceType(type)) {
let fields = objectValues(type.getFields());
if (!includeDeprecated) {
fields = fields.filter(field => !field.deprecationReason);
fields = fields.filter(field => !field.isDeprecated);
}
return fields;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ export const __Type = new GraphQLObjectType({
if (isEnumType(type)) {
let values = type.getValues();
if (!includeDeprecated) {
values = values.filter(value => !value.deprecationReason);
values = values.filter(value => !value.isDeprecated);
}
return values;
}
Expand Down