Skip to content

Commit 1a85ba2

Browse files
committed
Include directive argument types in getTypeMap()
1 parent 2616ced commit 1a85ba2

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/type/schema.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
isUnionType,
1414
isInputObjectType,
1515
isWrappingType,
16+
getNamedType,
1617
} from './definition';
1718
import type {
1819
GraphQLType,
@@ -22,7 +23,11 @@ import type {
2223
GraphQLInterfaceType,
2324
} from './definition';
2425
import type { SchemaDefinitionNode } from '../language/ast';
25-
import { GraphQLDirective, specifiedDirectives } from './directives';
26+
import {
27+
GraphQLDirective,
28+
isDirective,
29+
specifiedDirectives,
30+
} from './directives';
2631
import type { GraphQLError } from '../error/GraphQLError';
2732
import { __Schema } from './introspection';
2833
import find from '../jsutils/find';
@@ -121,6 +126,10 @@ export class GraphQLSchema {
121126
initialTypes = initialTypes.concat(types);
122127
}
123128

129+
initialTypes = initialTypes.concat(
130+
...this._directives.map(directive => getDirectiveArgTypes(directive)),
131+
);
132+
124133
this._typeMap = initialTypes.reduce(
125134
typeMapReducer,
126135
(Object.create(null): TypeMap),
@@ -269,3 +278,10 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {
269278

270279
return reducedMap;
271280
}
281+
282+
function getDirectiveArgTypes(directive: GraphQLDirective) {
283+
if (!isDirective(directive)) {
284+
return [];
285+
}
286+
return directive.args.map(arg => getNamedType(arg.type));
287+
}

0 commit comments

Comments
 (0)