|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Railt package. |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Railt\SDL\Executor\Extension; |
|
13
|
|
|
|
|
14
|
|
|
use Railt\SDL\Document; |
|
15
|
|
|
use Phplrt\Visitor\Visitor; |
|
16
|
|
|
use Railt\SDL\Builder\Factory; |
|
17
|
|
|
use Railt\SDL\Executor\Registry; |
|
18
|
|
|
use Railt\SDL\Ast\DefinitionNode; |
|
19
|
|
|
use GraphQL\Contracts\TypeSystem\Type\TypeInterface; |
|
20
|
|
|
use GraphQL\Contracts\TypeSystem\DefinitionInterface; |
|
21
|
|
|
use GraphQL\Contracts\TypeSystem\Type\NamedTypeInterface; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Class ExtensionExecutor |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract class ExtensionExecutor extends Visitor |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* @var Factory |
|
30
|
|
|
*/ |
|
31
|
|
|
private Factory $factory; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var Registry |
|
35
|
|
|
*/ |
|
36
|
|
|
private Registry $registry; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var Document |
|
40
|
|
|
*/ |
|
41
|
|
|
protected Document $document; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* ExtensionExecutor constructor. |
|
45
|
|
|
* |
|
46
|
|
|
* @param Factory $factory |
|
47
|
|
|
* @param Document $document |
|
48
|
|
|
* @param Registry $registry |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(Factory $factory, Document $document, Registry $registry) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->factory = $factory; |
|
53
|
|
|
$this->registry = $registry; |
|
54
|
|
|
$this->document = $document; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param DefinitionNode $node |
|
59
|
|
|
* @return DefinitionInterface |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function build(DefinitionNode $node): DefinitionInterface |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->factory->build($node, $this->registry); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param string $type |
|
68
|
|
|
* @return NamedTypeInterface |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function fetch(string $type): NamedTypeInterface |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->factory->fetch($type, $this->registry); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|