Files
kupshop/bundles/KupShop/GraphQLBundle/ApiShared/Util/GraphQLUtil.php
2025-08-02 16:30:27 +02:00

28 lines
582 B
PHP

<?php
declare(strict_types=1);
namespace KupShop\GraphQLBundle\ApiShared\Util;
use GraphQL\Type\Definition\ResolveInfo;
class GraphQLUtil
{
public function lookAhead(ResolveInfo $resolveInfo, array $path): ?array
{
$queryPlan = $resolveInfo->lookAhead()->queryPlan();
if (!($current = $queryPlan[array_shift($path)] ?? null)) {
return null;
}
foreach ($path as $item) {
if (!($current = $current['fields'][$item] ?? null)) {
return null;
}
}
return $current;
}
}