Skip to content

Commit

Permalink
Include directive argument types in getTypeMap()
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogu committed Jan 3, 2018
1 parent 2616ced commit 7321a18
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/type/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
isUnionType,
isInputObjectType,
isWrappingType,
getNamedType,
} from './definition';
import type {
GraphQLType,
Expand All @@ -22,7 +23,11 @@ import type {
GraphQLInterfaceType,
} from './definition';
import type { SchemaDefinitionNode } from '../language/ast';
import { GraphQLDirective, specifiedDirectives } from './directives';
import {
GraphQLDirective,
isDirective,
specifiedDirectives,
} from './directives';
import type { GraphQLError } from '../error/GraphQLError';
import { __Schema } from './introspection';
import find from '../jsutils/find';
Expand Down Expand Up @@ -121,6 +126,10 @@ export class GraphQLSchema {
initialTypes = initialTypes.concat(types);
}

initialTypes = initialTypes.concat(
...this._directives.map(directive => getDirectiveArgTypes(directive)),
);

this._typeMap = initialTypes.reduce(
typeMapReducer,
(Object.create(null): TypeMap),
Expand Down Expand Up @@ -269,3 +278,10 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {

return reducedMap;
}

function getDirectiveArgTypes(directive: GraphQLDirective) {
if (!isDirective(directive)) {
return [];
}
return directive.args.map(arg => getNamedType(arg.type));
}

0 comments on commit 7321a18

Please sign in to comment.