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

api-platform / core / 15133993414

20 May 2025 09:30AM UTC coverage: 26.313% (-1.2%) from 27.493%
15133993414

Pull #7161

github

web-flow
Merge e2c03d45f into 5459ba375
Pull Request #7161: fix(metadata): infer parameter string type from schema

0 of 2 new or added lines in 1 file covered. (0.0%)

11019 existing lines in 363 files now uncovered.

12898 of 49018 relevant lines covered (26.31%)

34.33 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
    {
33
        parent::__construct();
1✔
34
    }
35

36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function configure(): void
40
    {
41
        $this
1✔
42
            ->setDescription('Export the GraphQL schema in Schema Definition Language (SDL)')
1✔
43
            ->addOption('comment-descriptions', null, InputOption::VALUE_NONE, 'Use preceding comments as the description (deprecated: graphql-php < 15)')
1✔
44
            ->addOption('sort-types', null, InputOption::VALUE_NONE, 'Order types alphabetically')
1✔
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
    {
53
        $io = new SymfonyStyle($input, $output);
1✔
54

55
        $options = [];
1✔
56

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

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

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

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

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