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

overblog / GraphQLBundle / 44864298542

20 Nov 2026 05:43PM UTC coverage: 98.547% (+0.3%) from 98.287%
44864298542

push

github

web-flow
fix: failing pipeline (#1252)

* fix: ignore specifiedBy schema entries in dump schema tests

Newer webonyx/graphql-php versions add the @specifiedBy directive and the
__Type.specifiedByURL field to introspection output. Strip them from both
expected and actual JSON so the fixtures stay valid across versions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix: ignore phpstan covariance error on CustomScalarType::$config

The bundle's config shape adds the "scalarType" key, so it cannot be
covariant with the parent's type. Suppress it as webonyx does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Max Baldanza <max.baldanza@angi.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

4545 of 4612 relevant lines covered (98.55%)

76.58 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 {
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 TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc