GraphQL\Executor\Executor::completeValueCatchingError PHP Метод

completeValueCatchingError() приватный статический Метод

This is a small wrapper around completeValue which detects and logs errors in the execution context.
private static completeValueCatchingError ( ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result ) : array | null | GraphQL\Executor\Promise\Promise
$exeContext ExecutionContext
$returnType GraphQL\Type\Definition\Type
$fieldNodes
$info GraphQL\Type\Definition\ResolveInfo
$path
$result
Результат array | null | GraphQL\Executor\Promise\Promise
    private static function completeValueCatchingError(ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result)
    {
        // If the field type is non-nullable, then it is resolved without any
        // protection from errors.
        if ($returnType instanceof NonNull) {
            return self::completeValueWithLocatedError($exeContext, $returnType, $fieldNodes, $info, $path, $result);
        }
        // Otherwise, error protection is applied, logging the error and resolving
        // a null value for this field if one is encountered.
        try {
            $completed = self::completeValueWithLocatedError($exeContext, $returnType, $fieldNodes, $info, $path, $result);
            if (self::$promiseAdapter->isPromise($completed)) {
                return $completed->then(null, function ($error) use($exeContext) {
                    $exeContext->addError($error);
                    return self::$promiseAdapter->createResolvedPromise(null);
                });
            }
            return $completed;
        } catch (Error $err) {
            // If `completeValueWithLocatedError` returned abruptly (threw an error), log the error
            // and return null.
            $exeContext->addError($err);
            return null;
        }
    }