From bb76a16558f8328a6fe3bdbdad6f92e7d47dc97b Mon Sep 17 00:00:00 2001 From: David Govea Date: Wed, 21 Apr 2021 01:43:31 -0700 Subject: [PATCH 1/3] add failing test for #2895 --- src/type/__tests__/introspection-test.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 478cc9bd18..b9eade3ef2 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -1,4 +1,4 @@ -import { expect } from 'chai'; +import { assert, expect } from 'chai'; import { describe, it } from 'mocha'; import invariant from '../../jsutils/invariant'; @@ -1586,4 +1586,25 @@ describe('Introspection', () => { }), ).to.not.throw(); }); + + it('can include deprecated input fields', () => { + const schema = buildSchema(` + type Query { + oldField(input: Boolean @deprecated(reason: "got over it")): String + } + `); + + const source = getIntrospectionQuery({ + inputValueDeprecation: true, + }); + + const { data, errors } = graphqlSync({ + schema, + source, + }); + + assert.isUndefined(errors, `Introspection query was not successful ${JSON.stringify(errors)}`); + assert.isOk(data); + }); + }); From a69c849b2a28611f4217469b4298d8f0b49bae61 Mon Sep 17 00:00:00 2001 From: David Govea Date: Wed, 21 Apr 2021 02:15:56 -0700 Subject: [PATCH 2/3] fix attempt 1: remove includeDeprecated from directive & adjust test --- src/utilities/__tests__/getIntrospectionQuery-test.js | 2 +- src/utilities/getIntrospectionQuery.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.js b/src/utilities/__tests__/getIntrospectionQuery-test.js index 3f0c36298f..c64db38adf 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.js +++ b/src/utilities/__tests__/getIntrospectionQuery-test.js @@ -108,7 +108,7 @@ describe('getIntrospectionQuery', () => { expectIntrospectionQuery({ inputValueDeprecation: true }).toMatch( 'includeDeprecated: true', - 5, + 4, ); expectIntrospectionQuery({ inputValueDeprecation: false }).toMatch( diff --git a/src/utilities/getIntrospectionQuery.js b/src/utilities/getIntrospectionQuery.js index 1c9abb4204..35ee0459c6 100644 --- a/src/utilities/getIntrospectionQuery.js +++ b/src/utilities/getIntrospectionQuery.js @@ -62,7 +62,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { ${descriptions} ${directiveIsRepeatable} locations - args${inputDeprecation('(includeDeprecated: true)')} { + args { ...InputValue } } From f03d93bd3cfde9c136e1ebcf013dadd5babff74f Mon Sep 17 00:00:00 2001 From: David Govea Date: Wed, 21 Apr 2021 10:40:59 -0700 Subject: [PATCH 3/3] fix flow types in new test --- src/type/__tests__/introspection-test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index b9eade3ef2..ca4e93936c 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -1603,8 +1603,10 @@ describe('Introspection', () => { source, }); - assert.isUndefined(errors, `Introspection query was not successful ${JSON.stringify(errors)}`); + assert.isUndefined( + errors, + `Introspection query was not successful ${JSON.stringify(errors) || ''}`, + ); assert.isOk(data); }); - });