diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 478cc9bd18..0d2fefcc31 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -761,7 +761,17 @@ describe('Introspection', () => { }, { name: 'args', - args: [], + args: [ + { + name: 'includeDeprecated', + type: { + kind: 'SCALAR', + name: 'Boolean', + ofType: null, + }, + defaultValue: 'false', + }, + ], type: { kind: 'NON_NULL', name: null, diff --git a/src/type/introspection.js b/src/type/introspection.js index 77362ed02d..f353a77284 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -106,7 +106,17 @@ export const __Directive = new GraphQLObjectType({ type: new GraphQLNonNull( new GraphQLList(new GraphQLNonNull(__InputValue)), ), - resolve: (directive) => directive.args, + args: { + includeDeprecated: { + type: GraphQLBoolean, + defaultValue: false, + }, + }, + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, }, }: GraphQLFieldConfigMap), }); diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.js b/src/utilities/__tests__/getIntrospectionQuery-test.js index 3f0c36298f..a097fc8e1b 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.js +++ b/src/utilities/__tests__/getIntrospectionQuery-test.js @@ -1,12 +1,26 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; +import { parse } from '../../language/parser'; + +import { validate } from '../../validation/validate'; + import type { IntrospectionOptions } from '../getIntrospectionQuery'; +import { buildSchema } from '../buildASTSchema'; import { getIntrospectionQuery } from '../getIntrospectionQuery'; +const dummySchema = buildSchema(` + type Query { + dummy: String + } +`); + function expectIntrospectionQuery(options?: IntrospectionOptions) { const query = getIntrospectionQuery(options); + const validationErrors = validate(dummySchema, parse(query)); + expect(validationErrors).to.deep.equal([]); + return { toMatch(name: string, times: number = 1): void { const pattern = toRegExp(name); diff --git a/src/utilities/__tests__/printSchema-test.js b/src/utilities/__tests__/printSchema-test.js index df064c3724..cce29f8077 100644 --- a/src/utilities/__tests__/printSchema-test.js +++ b/src/utilities/__tests__/printSchema-test.js @@ -766,7 +766,7 @@ describe('Type System Printer', () => { description: String isRepeatable: Boolean! locations: [__DirectiveLocation!]! - args: [__InputValue!]! + args(includeDeprecated: Boolean = false): [__InputValue!]! } """