Skip to content

Commit 2255959

Browse files
committed
1 parent 30b4469 commit 2255959

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/type/directives.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import type { DirectiveDefinitionNode } from '../language/ast';
99
import { DirectiveLocation } from '../language/directiveLocation';
1010

1111
import type {
12-
GraphQLArgument,
13-
GraphQLFieldConfigArgumentMap,
12+
GraphQLArgument, GraphQLEnumValue, GraphQLField,
13+
GraphQLFieldConfigArgumentMap, GraphQLInputField, GraphQLType,
1414
} from './definition';
1515
import { assertName } from './assertName';
1616
import { GraphQLString, GraphQLBoolean } from './scalars';
@@ -109,6 +109,8 @@ export class GraphQLDirective {
109109
}
110110
}
111111

112+
type DirectiveExposeArgs = (definition: GraphQLType|GraphQLField<unknown, unknown>|GraphQLEnumValue|GraphQLInputField|GraphQLArgument) => Record<string, string>
113+
112114
export interface GraphQLDirectiveConfig {
113115
name: string;
114116
description?: Maybe<string>;
@@ -117,6 +119,7 @@ export interface GraphQLDirectiveConfig {
117119
isRepeatable?: Maybe<boolean>;
118120
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
119121
astNode?: Maybe<DirectiveDefinitionNode>;
122+
exposeArgs?: Maybe<DirectiveExposeArgs>
120123
}
121124

122125
interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
@@ -191,6 +194,15 @@ export const GraphQLDeprecatedDirective: GraphQLDirective =
191194
defaultValue: DEFAULT_DEPRECATION_REASON,
192195
},
193196
},
197+
exposeArgs: (definition: GraphQLField<unknown, unknown>|GraphQLInputField|GraphQLEnumValue) => {
198+
if (definition.deprecationReason != null) {
199+
return [
200+
definition.deprecationReason === DEFAULT_DEPRECATION_REASON
201+
? {}
202+
: { reason: definition.deprecationReason },
203+
];
204+
}
205+
}
194206
});
195207

196208
/**

0 commit comments

Comments
 (0)