1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Overblog\GraphQLBundle\Command; |
6
|
|
|
|
7
|
|
|
use GraphQL\Error\InvariantViolation; |
8
|
|
|
use GraphQL\Error\Warning; |
9
|
|
|
use Overblog\GraphQLBundle\Request\Executor as RequestExecutor; |
10
|
|
|
use Symfony\Component\Console\Command\Command; |
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
12
|
|
|
use Symfony\Component\Console\Input\InputOption; |
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
14
|
|
|
|
15
|
|
|
final class ValidateCommand extends Command |
16
|
|
|
{ |
17
|
|
|
/** @var RequestExecutor */ |
18
|
|
|
private $requestExecutor; |
19
|
|
|
|
20
|
2 |
|
public function __construct(RequestExecutor $requestExecutor) |
21
|
|
|
{ |
22
|
2 |
|
parent::__construct(); |
23
|
2 |
|
$this->requestExecutor = $requestExecutor; |
24
|
2 |
|
} |
25
|
|
|
|
26
|
1 |
|
public function setRequestExecutor(RequestExecutor $requestExecutor): void |
27
|
|
|
{ |
28
|
1 |
|
$this->requestExecutor = $requestExecutor; |
29
|
1 |
|
} |
30
|
|
|
|
31
|
2 |
|
public function getRequestExecutor(): RequestExecutor |
32
|
|
|
{ |
33
|
2 |
|
return $this->requestExecutor; |
34
|
|
|
} |
35
|
|
|
|
36
|
2 |
|
protected function configure(): void |
37
|
|
|
{ |
38
|
|
|
$this |
39
|
2 |
|
->setName('graphql:validate') |
40
|
2 |
|
->setDescription('Validate schema') |
41
|
2 |
|
->addOption( |
42
|
2 |
|
'schema', |
43
|
2 |
|
null, |
44
|
2 |
|
InputOption::VALUE_OPTIONAL, |
45
|
2 |
|
'The schema name to validate.' |
46
|
|
|
) |
47
|
|
|
; |
48
|
2 |
|
} |
49
|
|
|
|
50
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output): void |
51
|
|
|
{ |
52
|
2 |
|
Warning::suppress(true); |
53
|
|
|
|
54
|
2 |
|
$schemaName = $input->getOption('schema'); |
55
|
2 |
|
$schema = $this->getRequestExecutor()->getSchema($schemaName); |
56
|
|
|
|
57
|
|
|
try { |
58
|
2 |
|
$schema->assertValid(); |
59
|
1 |
|
} catch (InvariantViolation $e) { |
|
|
|
|
60
|
1 |
|
$output->writeln('<comment>'.$e->getMessage().'</comment>'); |
61
|
|
|
|
62
|
1 |
|
return; |
63
|
|
|
} |
64
|
1 |
|
$output->writeln('<info>No error</info>'); |
65
|
1 |
|
} |
66
|
|
|
} |
67
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.