1 | <?php |
||
16 | abstract class AbstractSchema |
||
17 | { |
||
18 | |||
19 | /** @var SchemaConfig */ |
||
20 | protected $config; |
||
21 | |||
22 | 48 | public function __construct($config = []) |
|
23 | { |
||
24 | 48 | if (!array_key_exists('query', $config)) { |
|
25 | 32 | $config['query'] = new InternalSchemaQueryObject(['name' => $this->getName() . 'Query']); |
|
26 | } |
||
27 | 48 | if (!array_key_exists('mutation', $config)) { |
|
28 | 46 | $config['mutation'] = new InternalSchemaMutationObject(['name' => $this->getName() . 'Mutation']); |
|
29 | } |
||
30 | 48 | if (!array_key_exists('types', $config)) { |
|
31 | 48 | $config['types'] = []; |
|
32 | } |
||
33 | |||
34 | 48 | $this->config = new SchemaConfig($config, $this); |
|
35 | |||
36 | 48 | $this->build($this->config); |
|
37 | 48 | } |
|
38 | |||
39 | abstract public function build(SchemaConfig $config); |
||
40 | |||
41 | 40 | public function addQueryField($field, $fieldInfo = null) |
|
45 | |||
46 | 2 | public function addMutationField($field, $fieldInfo = null) |
|
50 | |||
51 | 48 | final public function getQueryType() |
|
55 | |||
56 | 30 | final public function getMutationType() |
|
60 | |||
61 | /** |
||
62 | * @return callable|mixed|null |
||
63 | */ |
||
64 | 5 | public function getTypes() |
|
68 | |||
69 | 35 | public function getName() |
|
75 | } |
||
76 |