Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SchemaGenerator.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
20 {
24  private $schemaFactory;
25 
29  private $outputMapper;
30 
34  private $config;
35 
41  public function __construct(
42  SchemaFactory $schemaFactory,
43  OutputMapper $outputMapper,
44  ConfigInterface $config
45  ) {
46  $this->schemaFactory = $schemaFactory;
47  $this->outputMapper = $outputMapper;
48  $this->config = $config;
49  }
50 
54  public function generate() : Schema
55  {
56  $schema = $this->schemaFactory->create(
57  [
58  'query' => $this->outputMapper->getOutputType('Query'),
59  'mutation' => $this->outputMapper->getOutputType('Mutation'),
60  'typeLoader' => function ($name) {
61  return $this->outputMapper->getOutputType($name);
62  },
63  'types' => function () {
64  //all types should be generated only on introspection
65  $typesImplementors = [];
66  foreach ($this->config->getDeclaredTypeNames() as $name) {
67  $typesImplementors [] = $this->outputMapper->getOutputType($name);
68  }
69  return $typesImplementors;
70  }
71  ]
72  );
73  return $schema;
74  }
75 }
$config
Definition: fraud_order.php:17
__construct(SchemaFactory $schemaFactory, OutputMapper $outputMapper, ConfigInterface $config)
if(!isset($_GET['name'])) $name
Definition: log.php:14