@@ -259,22 +259,14 @@ export class ASTDefinitionBuilder {
259259 field : FieldDefinitionNode ,
260260 typeName ?: string ,
261261 ) : GraphQLFieldConfig < mixed , mixed > {
262- const resolve =
263- ( typeName &&
264- this . _options &&
265- this . _options . resolvers &&
266- this . _options . resolvers [ typeName ] &&
267- this . _options . resolvers [ typeName ] [ field . name . value ] ) ||
268- undefined ;
269-
270262 return {
271263 // Note: While this could make assertions to get the correctly typed
272264 // value, that would throw immediately while type system validation
273265 // with validateSchema() will produce more actionable results.
274266 type : ( this . getWrappedType ( field . type ) : any ) ,
275267 description : getDescription ( field , this . _options ) ,
276268 args : keyByNameNode ( field . arguments || [ ] , arg => this . buildArg ( arg ) ) ,
277- resolve,
269+ resolve : this . _lookupResolver ( typeName , field . name . value ) ,
278270 deprecationReason : getDeprecationReason ( field ) ,
279271 astNode : field ,
280272 } ;
@@ -306,8 +298,12 @@ export class ASTDefinitionBuilder {
306298 } ;
307299 }
308300
309- buildEnumValue ( value : EnumValueDefinitionNode ) : GraphQLEnumValueConfig {
301+ buildEnumValue (
302+ value : EnumValueDefinitionNode ,
303+ typeName ?: string ,
304+ ) : GraphQLEnumValueConfig {
310305 return {
306+ value : this . _lookupResolver ( typeName , value . name . value ) ,
311307 description : getDescription ( value , this . _options ) ,
312308 deprecationReason : getDeprecationReason ( value ) ,
313309 astNode : value ,
@@ -389,11 +385,14 @@ export class ASTDefinitionBuilder {
389385
390386 _makeEnumDef ( astNode : EnumTypeDefinitionNode ) {
391387 const valueNodes = astNode . values || [ ] ;
388+ const name = astNode . name . value ;
392389
393390 return new GraphQLEnumType ( {
394- name : astNode . name . value ,
391+ name,
395392 description : getDescription ( astNode , this . _options ) ,
396- values : keyByNameNode ( valueNodes , value => this . buildEnumValue ( value ) ) ,
393+ values : keyByNameNode ( valueNodes , value =>
394+ this . buildEnumValue ( value , name ) ,
395+ ) ,
397396 astNode,
398397 } ) ;
399398 }
@@ -437,6 +436,17 @@ export class ASTDefinitionBuilder {
437436 astNode : def ,
438437 } ) ;
439438 }
439+
440+ _lookupResolver ( typeName : ?string , key : string ) {
441+ return (
442+ ( typeName &&
443+ this . _options &&
444+ this . _options . resolvers &&
445+ this . _options . resolvers [ typeName ] &&
446+ this . _options . resolvers [ typeName ] [ key ] ) ||
447+ undefined
448+ ) ;
449+ }
440450}
441451
442452function keyByNameNode < T : { + name : NameNode , ... } , V > (
0 commit comments