private static function completeAbstractValue(ExecutionContext $exeContext, AbstractType $returnType, $fieldNodes, ResolveInfo $info, $path, &$result)
{
$runtimeType = $returnType->resolveType($result, $exeContext->contextValue, $info);
if (null === $runtimeType) {
$runtimeType = self::inferTypeOf($result, $exeContext->contextValue, $info, $returnType);
}
// If resolveType returns a string, we assume it's a ObjectType name.
if (is_string($runtimeType)) {
$runtimeType = $exeContext->schema->getType($runtimeType);
}
if (!$runtimeType instanceof ObjectType) {
throw new Error("Abstract type {$returnType} must resolve to an Object type at runtime " . "for field {$info->parentType}.{$info->fieldName} with value \"" . print_r($result, true) . "\"," . "received \"{$runtimeType}\".", $fieldNodes);
}
if (!$exeContext->schema->isPossibleType($returnType, $runtimeType)) {
throw new Error("Runtime Object type \"{$runtimeType}\" is not a possible type for \"{$returnType}\".", $fieldNodes);
}
return self::completeObjectValue($exeContext, $runtimeType, $fieldNodes, $info, $path, $result);
}