We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
15 | final class GraphQLDumpSchemaCommand extends Command |
||
16 | { |
||
17 | /** @var ContainerInterface */ |
||
18 | private $container; |
||
19 | |||
20 | /** @var string */ |
||
21 | private $baseExportPath; |
||
22 | |||
23 | 7 | public function __construct( |
|
31 | |||
32 | 7 | protected function configure() |
|
71 | |||
72 | 7 | protected function execute(InputInterface $input, OutputInterface $output) |
|
78 | |||
79 | 7 | private function createFile(InputInterface $input) |
|
80 | { |
||
81 | 7 | $format = strtolower($input->getOption('format')); |
|
82 | 7 | $schemaName = $input->getOption('schema'); |
|
83 | |||
84 | 7 | $file = $input->getOption('file') ?: $this->baseExportPath.sprintf('/../var/schema%s.%s', $schemaName ? '.'.$schemaName : '', $format); |
|
85 | |||
86 | 7 | switch ($format) { |
|
87 | case 'json': |
||
88 | $request = [ |
||
89 | 5 | 'query' => Introspection::getIntrospectionQuery(false), |
|
90 | 'variables' => [], |
||
91 | 'operationName' => null, |
||
92 | ]; |
||
93 | |||
94 | 5 | $modern = $this->useModernJsonFormat($input); |
|
95 | |||
96 | 4 | $result = $this->getRequestExecutor() |
|
97 | 4 | ->execute($request, [], $schemaName) |
|
98 | 4 | ->toArray(); |
|
99 | |||
100 | 4 | $content = json_encode($modern ? $result : $result['data'], \JSON_PRETTY_PRINT); |
|
101 | 4 | break; |
|
102 | |||
103 | case 'graphql': |
||
104 | 1 | $content = SchemaPrinter::doPrint($this->getRequestExecutor()->getSchema($schemaName)); |
|
105 | 1 | break; |
|
106 | |||
107 | default: |
||
108 | 1 | throw new \InvalidArgumentException(sprintf('Unknown format %s.', json_encode($format))); |
|
109 | } |
||
110 | |||
111 | 5 | file_put_contents($file, $content); |
|
112 | |||
113 | 5 | return $file; |
|
114 | } |
||
115 | |||
116 | 5 | private function useModernJsonFormat(InputInterface $input) |
|
126 | |||
127 | /** |
||
128 | * @return RequestExecutor |
||
129 | */ |
||
130 | 5 | private function getRequestExecutor() |
|
134 | } |
||
135 |