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

type/introspection: add missing __Directive.args(includeDeprecated:) #3273

Merged
merged 1 commit into from Sep 24, 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
12 changes: 11 additions & 1 deletion src/type/__tests__/introspection-test.ts
Expand Up @@ -763,7 +763,17 @@ describe('Introspection', () => {
},
{
name: 'args',
args: [],
args: [
{
name: 'includeDeprecated',
type: {
kind: 'SCALAR',
name: 'Boolean',
ofType: null,
},
defaultValue: 'false',
},
],
type: {
kind: 'NON_NULL',
name: null,
Expand Down
12 changes: 11 additions & 1 deletion src/type/introspection.ts
Expand Up @@ -104,7 +104,17 @@ export const __Directive: GraphQLObjectType = 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);
},
},
} as GraphQLFieldConfigMap<GraphQLDirective, unknown>),
});
Expand Down
14 changes: 14 additions & 0 deletions src/utilities/__tests__/getIntrospectionQuery-test.ts
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/printSchema-test.ts
Expand Up @@ -767,7 +767,7 @@ describe('Type System Printer', () => {
description: String
isRepeatable: Boolean!
locations: [__DirectiveLocation!]!
args: [__InputValue!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
}

"""
Expand Down