@@ -40,6 +40,7 @@ import type {
40
40
GraphQLAbstractType ,
41
41
GraphQLField ,
42
42
GraphQLFieldResolver ,
43
+ GraphQLTypeResolver ,
43
44
GraphQLResolveInfo ,
44
45
ResponsePath ,
45
46
GraphQLList ,
@@ -1027,9 +1028,10 @@ function completeAbstractValue(
1027
1028
path: ResponsePath,
1028
1029
result: mixed,
1029
1030
): MaybePromise< ObjMap < mixed > > {
1030
- const runtimeType = returnType . resolveType
1031
- ? returnType . resolveType ( result , exeContext . contextValue , info )
1032
- : defaultResolveTypeFn ( result , exeContext . contextValue , info , returnType ) ;
1031
+ const resolveTypeFn = returnType . resolveType || defaultResolveType ;
1032
+ const contextValue = exeContext . contextValue ;
1033
+ const typeInfo = { ...info , valueType : returnType , valuePath : path } ;
1034
+ const runtimeType = resolveTypeFn ( result , contextValue , typeInfo ) ;
1033
1035
1034
1036
if ( isPromise ( runtimeType ) ) {
1035
1037
return runtimeType . then ( resolvedRuntimeType =>
@@ -1211,12 +1213,11 @@ function _collectSubfields(
1211
1213
* Otherwise, test each possible type for the abstract type by calling
1212
1214
* isTypeOf for the object being coerced, returning the first type that matches.
1213
1215
*/
1214
- function defaultResolveTypeFn (
1215
- value : mixed ,
1216
- contextValue : mixed ,
1217
- info : GraphQLResolveInfo ,
1218
- abstractType : GraphQLAbstractType ,
1219
- ) : MaybePromise < ?GraphQLObjectType | string > {
1216
+ const defaultResolveType : GraphQLTypeResolver < any , * > = function (
1217
+ value ,
1218
+ contextValue ,
1219
+ info ,
1220
+ ) {
1220
1221
// First, look for `__typename`.
1221
1222
if (
1222
1223
value !== null &&
@@ -1227,7 +1228,7 @@ function defaultResolveTypeFn(
1227
1228
}
1228
1229
1229
1230
// Otherwise, test each possible type.
1230
- const possibleTypes = info . schema . getPossibleTypes ( abstractType ) ;
1231
+ const possibleTypes = info . schema . getPossibleTypes ( info . valueType ) ;
1231
1232
const promisedIsTypeOfResults = [ ] ;
1232
1233
1233
1234
for ( let i = 0 ; i < possibleTypes . length ; i ++ ) {
@@ -1253,7 +1254,7 @@ function defaultResolveTypeFn(
1253
1254
}
1254
1255
} ) ;
1255
1256
}
1256
- }
1257
+ } ;
1257
1258
1258
1259
/**
1259
1260
* If a resolve function is not given, then a default resolve behavior is used
0 commit comments