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

api-platform / core / 13724522058

07 Mar 2025 04:04PM UTC coverage: 8.175% (-0.3%) from 8.518%
13724522058

Pull #7005

github

web-flow
Merge 322407532 into 1e0bc9dc8
Pull Request #7005: fix(validation): deprecate string message for ValidationException con…

4 of 6 new or added lines in 1 file covered. (66.67%)

159 existing lines in 24 files now uncovered.

12839 of 157045 relevant lines covered (8.18%)

13.55 hits per line

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

80.0
/src/Symfony/Bundle/Command/GraphQlExportCommand.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Symfony\Bundle\Command;
15

16
use ApiPlatform\GraphQl\Type\SchemaBuilderInterface;
17
use GraphQL\Utils\SchemaPrinter;
18
use Symfony\Component\Console\Command\Command;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Input\InputOption;
21
use Symfony\Component\Console\Output\OutputInterface;
22
use Symfony\Component\Console\Style\SymfonyStyle;
23

24
/**
25
 * Export the GraphQL schema in Schema Definition Language (SDL).
26
 *
27
 * @author Alan Poulain <contact@alanpoulain.eu>
28
 */
29
class GraphQlExportCommand extends Command
30
{
31
    public function __construct(private readonly SchemaBuilderInterface $schemaBuilder)
32
    {
UNCOV
33
        parent::__construct();
1✔
34
    }
35

36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function configure(): void
40
    {
UNCOV
41
        $this
1✔
UNCOV
42
            ->setDescription('Export the GraphQL schema in Schema Definition Language (SDL)')
1✔
UNCOV
43
            ->addOption('comment-descriptions', null, InputOption::VALUE_NONE, 'Use preceding comments as the description (deprecated: graphql-php < 15)')
1✔
UNCOV
44
            ->addOption('sort-types', null, InputOption::VALUE_NONE, 'Order types alphabetically')
1✔
UNCOV
45
            ->addOption('output', 'o', InputOption::VALUE_REQUIRED, 'Write output to file');
1✔
46
    }
47

48
    /**
49
     * {@inheritdoc}
50
     */
51
    protected function execute(InputInterface $input, OutputInterface $output): int
52
    {
UNCOV
53
        $io = new SymfonyStyle($input, $output);
1✔
54

UNCOV
55
        $options = [];
1✔
56

57
        // Removed in graphql-php 15
UNCOV
58
        if ($input->getOption('comment-descriptions')) {
1✔
59
            $options['commentDescriptions'] = true;
×
60
        }
UNCOV
61
        if ($input->getOption('sort-types')) {
1✔
62
            $options['sortTypes'] = true;
×
63
        }
64

UNCOV
65
        $schemaExport = SchemaPrinter::doPrint($this->schemaBuilder->getSchema(), $options);
1✔
66

UNCOV
67
        $filename = $input->getOption('output');
1✔
UNCOV
68
        if (\is_string($filename)) {
1✔
69
            file_put_contents($filename, $schemaExport);
×
70
            $io->success(\sprintf('Data written to %s.', $filename));
×
71
        } else {
UNCOV
72
            $output->writeln($schemaExport);
1✔
73
        }
74

UNCOV
75
        return \defined(Command::class.'::SUCCESS') ? Command::SUCCESS : 0;
1✔
76
    }
77

78
    public static function getDefaultName(): string
79
    {
80
        return 'api:graphql:export';
3✔
81
    }
82
}
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

© 2025 Coveralls, Inc