-
Notifications
You must be signed in to change notification settings - Fork 2k
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
getTypeMap() does not include input types used in directives #1189
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import { | |
isUnionType, | ||
isInputObjectType, | ||
isWrappingType, | ||
getNamedType, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Yogu Looks great now! One last issue from me: Can you please remove this line? |
||
} from './definition'; | ||
import type { | ||
GraphQLType, | ||
|
@@ -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'; | ||
|
@@ -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), | ||
|
@@ -269,3 +278,11 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap { | |
|
||
return reducedMap; | ||
} | ||
|
||
function getDirectiveArgTypes(directive: GraphQLDirective) { | ||
// directives are not validated until validateSchema() is called, so be defensive | ||
if (!isDirective(directive)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a test that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Yogu Make sense 👍 |
||
return []; | ||
} | ||
return directive.args.map(arg => arg.type); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to also test wrapped type maybe as one more argument