1 | <?php |
||
17 | class Schema |
||
18 | { |
||
19 | |||
20 | /** @var SchemaConfig */ |
||
21 | protected $config; |
||
22 | |||
23 | 16 | public function __construct($config = []) |
|
24 | { |
||
25 | 16 | if (!array_key_exists('query', $config)) { |
|
26 | 10 | $config['query'] = new ObjectType(['name' => $this->getName()]); |
|
27 | } |
||
28 | |||
29 | 16 | if (!array_key_exists('mutation', $config)) { |
|
30 | 16 | $config['mutation'] = new InputObjectType(['name' => $this->getName()]); |
|
31 | } |
||
32 | |||
33 | 16 | $this->config = new SchemaConfig($config, $this); |
|
34 | |||
35 | 15 | $this->build($this->config); |
|
36 | 15 | } |
|
37 | |||
38 | 9 | public function build(SchemaConfig $config) |
|
41 | |||
42 | 14 | public function addQuery($name, AbstractObjectType $query, $config = []) |
|
46 | |||
47 | public function addMutation($name, AbstractObjectType $query, $config = []) |
||
51 | |||
52 | 14 | final public function getQueryType() |
|
56 | |||
57 | final public function getMutationType() |
||
61 | |||
62 | 15 | public function getName() |
|
68 | |||
69 | } |