|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Digia\GraphQL\Language\Node; |
|
4
|
|
|
|
|
5
|
|
|
use Digia\GraphQL\Language\Location; |
|
6
|
|
|
|
|
7
|
|
|
class OperationDefinitionNode extends AbstractNode implements ExecutableDefinitionNodeInterface, |
|
8
|
|
|
DirectivesAwareInterface, NameAwareInterface |
|
9
|
|
|
{ |
|
10
|
|
|
use NameTrait; |
|
11
|
|
|
use DirectivesTrait; |
|
12
|
|
|
use VariableDefinitionsTrait; |
|
13
|
|
|
use SelectionSetTrait; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $operation; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* OperationDefinitionNode constructor. |
|
22
|
|
|
* |
|
23
|
|
|
* @param string $operation |
|
24
|
|
|
* @param NameNode|null $name |
|
25
|
|
|
* @param VariableDefinitionNode[] $variableDefinitions |
|
26
|
|
|
* @param DirectiveNode[] $directives |
|
27
|
|
|
* @param SelectionSetNode|null $selectionSet |
|
28
|
|
|
* @param Location|null $location |
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct( |
|
31
|
|
|
string $operation, |
|
32
|
|
|
?NameNode $name, |
|
33
|
|
|
array $variableDefinitions, |
|
34
|
|
|
array $directives, |
|
35
|
|
|
?SelectionSetNode $selectionSet, |
|
36
|
|
|
?Location $location |
|
37
|
|
|
) { |
|
38
|
|
|
parent::__construct(NodeKindEnum::OPERATION_DEFINITION, $location); |
|
39
|
|
|
|
|
40
|
|
|
$this->operation = $operation; |
|
41
|
|
|
$this->name = $name; |
|
42
|
|
|
$this->variableDefinitions = $variableDefinitions; |
|
43
|
|
|
$this->directives = $directives; |
|
44
|
|
|
$this->selectionSet = $selectionSet; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getOperation(): string |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->operation; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
*/ |
|
58
|
|
|
public function toAST(): array |
|
59
|
|
|
{ |
|
60
|
|
|
return [ |
|
61
|
|
|
'kind' => $this->kind, |
|
62
|
|
|
'loc' => $this->getLocationAST(), |
|
63
|
|
|
'operation' => $this->operation, |
|
64
|
|
|
'name' => $this->getNameAST(), |
|
65
|
|
|
'variableDefinitions' => $this->getVariableDefinitionsAST(), |
|
66
|
|
|
'directives' => $this->getDirectivesAST(), |
|
67
|
|
|
'selectionSet' => $this->getSelectionSetAST(), |
|
68
|
|
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|