• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

overblog / GraphQLBundle / 21452238007

28 Jan 2026 07:19PM UTC coverage: 98.546% (-0.02%) from 98.563%
21452238007

push

github

web-flow
adding symfony8 to supported list (#1228)

* adding symfony8 to supported list

* one more exclude, monolog bump

* bump doctrine

* doctrine annotations also

* Revert "doctrine annotations also"

This reverts commit aa26b8191.

* annotations 2.0 once more

* opt-out from annotation if doctrine/orm >= 3

* fix: bridge

* eliminate phpstan concenrns

* trying to make validation tests pass

* Revert "trying to make validation tests pass"

This reverts commit 2553168d1.

* do not skip tests

* Revert "do not skip tests"

This reverts commit d100da0c3.

* monolog bump

* Revert "Revert "trying to make validation tests pass""

This reverts commit b987e43b9.

* Revert "Revert "Revert "trying to make validation tests pass"""

This reverts commit ef4fb3a3a.

* works for php8.4, sf8

* cq

* cleanup

* proper order is now, hmmm ...

* reduce tests scope

remove choice validation from tests as it was not consistent with other
validators in version symfony/validator:7.3.*

* cq

* exclude phps prior to 8.4 from testing with sf8

* apply sorting on responses before comparing

no need to expect same

* do not test sf7 with 8.1

* exclude 7.2 lowest deps as issue with sorting in tests

* sf8 one more exclude

* fix CI config

* handle parameters by name

* revert index.md

* fix cs and cleanup

* collect coverage information from 2 jobs

* fix cs

---------

Co-authored-by: Tobias Nyholm <tobias.nyholm@gmail.com>

16 of 18 new or added lines in 2 files covered. (88.89%)

53 existing lines in 9 files now uncovered.

4541 of 4608 relevant lines covered (98.55%)

76.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Config/Parser/GraphQLParser.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Overblog\GraphQLBundle\Config\Parser;
6

7
use Exception;
8
use GraphQL\Language\AST\DefinitionNode;
9
use GraphQL\Language\AST\EnumTypeDefinitionNode;
10
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
11
use GraphQL\Language\AST\NodeKind;
12
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
13
use GraphQL\Language\Parser;
14
use SplFileInfo;
15
use Symfony\Component\Config\Resource\FileResource;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
18

19
use function array_keys;
20
use function array_pop;
21
use function call_user_func;
22
use function explode;
23
use function file_get_contents;
24
use function in_array;
25
use function preg_replace;
26
use function sprintf;
27
use function trim;
28
use function ucfirst;
29

30
final class GraphQLParser implements ParserInterface
31
{
32
    private const DEFINITION_TYPE_MAPPING = [
33
        NodeKind::OBJECT_TYPE_DEFINITION => 'object',
34
        NodeKind::INTERFACE_TYPE_DEFINITION => 'interface',
35
        NodeKind::ENUM_TYPE_DEFINITION => 'enum',
36
        NodeKind::UNION_TYPE_DEFINITION => 'union',
37
        NodeKind::INPUT_OBJECT_TYPE_DEFINITION => 'inputObject',
38
        NodeKind::SCALAR_TYPE_DEFINITION => 'customScalar',
39
    ];
40

41
    public static function parse(SplFileInfo $file, ContainerBuilder $container, array $configs = []): array
42
    {
43
        $container->addResource(new FileResource($file->getRealPath()));
11✔
44
        $content = trim((string) file_get_contents($file->getPathname()));
11✔
45
        $typesConfig = [];
11✔
46

47
        // allow empty files
48
        if (empty($content)) {
11✔
49
            return [];
2✔
50
        }
51
        try {
52
            $ast = Parser::parse($content);
9✔
53
        } catch (Exception $e) {
2✔
54
            throw new InvalidArgumentException(sprintf('An error occurred while parsing the file "%s".', $file), $e->getCode(), $e);
2✔
55
        }
56

57
        foreach ($ast->definitions as $typeDef) {
7✔
58
            /**
59
             * @var ObjectTypeDefinitionNode|InputObjectTypeDefinitionNode|EnumTypeDefinitionNode $typeDef
60
             */
61
            if (isset($typeDef->kind) && in_array($typeDef->kind, array_keys(self::DEFINITION_TYPE_MAPPING))) {
7✔
62
                /**
63
                 * @var class-string $class
64
                 */
65
                $class = sprintf('\\%s\\GraphQL\\ASTConverter\\%sNode', __NAMESPACE__, ucfirst(self::DEFINITION_TYPE_MAPPING[$typeDef->kind]));
5✔
66
                $astConverterCallable = [$class, 'toConfig'];
5✔
67
                if (is_callable($astConverterCallable)) {
5✔
68
                    $typesConfig[$typeDef->name->value] = call_user_func($astConverterCallable, $typeDef);
5✔
69
                } else {
UNCOV
70
                    self::throwUnsupportedDefinitionNode($typeDef);
3✔
71
                }
72
            } else {
73
                self::throwUnsupportedDefinitionNode($typeDef);
2✔
74
            }
75
        }
76

77
        return $typesConfig;
5✔
78
    }
79

80
    private static function throwUnsupportedDefinitionNode(DefinitionNode $typeDef): void
81
    {
82
        $path = explode('\\', $typeDef::class);
2✔
83
        throw new InvalidArgumentException(
2✔
84
            sprintf(
2✔
85
                '%s definition is not supported right now.',
2✔
86
                preg_replace('@DefinitionNode$@', '', array_pop($path))
2✔
87
            )
2✔
88
        );
2✔
89
    }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc