@@ -949,47 +949,55 @@ function completeAbstractValue(
949
949
const runtimeTypePromise : Promise < GraphQLObjectType | string > =
950
950
( runtimeType : any ) ;
951
951
return runtimeTypePromise . then ( resolvedRuntimeType =>
952
- validateRuntimeTypeAndCompleteObjectValue (
952
+ completeObjectValue (
953
953
exeContext ,
954
954
returnType ,
955
955
fieldNodes ,
956
956
info ,
957
957
path ,
958
- ensureType ( exeContext . schema , resolvedRuntimeType ) ,
958
+ ensureValidRuntimeType (
959
+ resolvedRuntimeType ,
960
+ exeContext ,
961
+ returnType ,
962
+ fieldNodes ,
963
+ info ,
964
+ result
965
+ ) ,
959
966
result
960
967
)
961
968
) ;
962
969
}
963
970
964
- return validateRuntimeTypeAndCompleteObjectValue (
971
+ return completeObjectValue (
965
972
exeContext ,
966
973
returnType ,
967
974
fieldNodes ,
968
975
info ,
969
976
path ,
970
- ensureType ( exeContext . schema , runtimeType ) ,
977
+ ensureValidRuntimeType (
978
+ resolvedRuntimeType ,
979
+ exeContext ,
980
+ returnType ,
981
+ fieldNodes ,
982
+ info ,
983
+ result
984
+ ) ,
971
985
result
972
986
) ;
973
987
}
974
988
975
- function ensureType(
976
- schema: GraphQLSchema,
977
- typeOrName: string | GraphQLObjectType
978
- ): GraphQLObjectType {
979
- return typeof typeOrName === 'string' ?
980
- schema . getType ( typeOrName ) :
981
- typeOrName ;
982
- }
983
-
984
- function validateRuntimeTypeAndCompleteObjectValue(
989
+ function ensureValidRuntimeType(
990
+ runtimeTypeOrName: string | GraphQLObjectType | void
985
991
exeContext: ExecutionContext,
986
992
returnType: GraphQLAbstractType,
987
993
fieldNodes: Array< FieldNode > ,
988
994
info: GraphQLResolveInfo,
989
- path: ResponsePath,
990
- runtimeType: GraphQLObjectType,
991
995
result: mixed
992
- ): mixed {
996
+ ): GraphQLObjectType {
997
+ const runtimeType = typeof runtimeTypeOrName === 'string' ?
998
+ exeContext . schema . getType ( runtimeTypeOrName ) :
999
+ runtimeTypeOrName ;
1000
+
993
1001
if ( ! ( runtimeType instanceof GraphQLObjectType ) ) {
994
1002
throw new GraphQLError (
995
1003
`Abstract type ${ returnType . name } must resolve to an Object type at ` +
@@ -1007,14 +1015,7 @@ function validateRuntimeTypeAndCompleteObjectValue(
1007
1015
) ;
1008
1016
}
1009
1017
1010
- return completeObjectValue(
1011
- exeContext,
1012
- runtimeType,
1013
- fieldNodes,
1014
- info,
1015
- path,
1016
- result
1017
- );
1018
+ return runtimeType ;
1018
1019
}
1019
1020
1020
1021
/**
0 commit comments