1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is a part of graphql-youshido project. |
4
|
|
|
* |
5
|
|
|
* @author Alexandr Viniychuk <[email protected]> |
6
|
|
|
* created: 11/28/15 3:53 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Youshido\GraphQL\Config\Schema; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
use Youshido\GraphQL\Config\AbstractConfig; |
13
|
|
|
use Youshido\GraphQL\Type\Object\AbstractObjectType; |
14
|
|
|
use Youshido\GraphQL\Type\Object\ObjectType; |
15
|
|
|
use Youshido\GraphQL\Type\TypeService; |
16
|
|
|
|
17
|
|
|
class SchemaConfig extends AbstractConfig |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
public function getRules() |
21
|
|
|
{ |
22
|
|
|
return [ |
23
|
|
|
'query' => ['type' => TypeService::TYPE_OBJECT_TYPE, 'required' => true], |
24
|
|
|
'mutation' => ['type' => TypeService::TYPE_OBJECT_TYPE], |
25
|
|
|
'types' => ['type' => TypeService::TYPE_ARRAY], |
26
|
|
|
'name' => ['type' => TypeService::TYPE_STRING], |
27
|
|
|
|
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return AbstractObjectType |
33
|
|
|
*/ |
34
|
48 |
|
public function getQuery() |
35
|
|
|
{ |
36
|
48 |
|
return $this->data['query']; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $query AbstractObjectType |
41
|
|
|
* |
42
|
|
|
* @return SchemaConfig |
43
|
|
|
*/ |
44
|
7 |
|
public function setQuery($query) |
45
|
|
|
{ |
46
|
7 |
|
$this->data['query'] = $query; |
47
|
|
|
|
48
|
7 |
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return ObjectType |
53
|
|
|
*/ |
54
|
40 |
|
public function getMutation() |
55
|
|
|
{ |
56
|
40 |
|
return $this->get('mutation'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param $query AbstractObjectType |
61
|
|
|
* |
62
|
|
|
* @return SchemaConfig |
63
|
|
|
*/ |
64
|
|
|
public function setMutation($query) |
65
|
|
|
{ |
66
|
|
|
$this->data['mutation'] = $query; |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getName() |
72
|
|
|
{ |
73
|
|
|
return $this->get('name', 'RootSchema'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param array $types |
78
|
|
|
* |
79
|
|
|
* @return $this |
80
|
|
|
*/ |
81
|
|
|
public function setTypes(array $types) { |
82
|
|
|
$this->data['types'] = $types; |
83
|
|
|
|
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return callable|mixed|null |
89
|
|
|
*/ |
90
|
5 |
|
public function getTypes() { |
91
|
5 |
|
return $this->get('types'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
} |
95
|
|
|
|