|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of Railt package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Railt\Adapters\Webonyx\Builders; |
|
11
|
|
|
|
|
12
|
|
|
use GraphQL\Type\Schema; |
|
|
|
|
|
|
13
|
|
|
use Railt\Compiler\Reflection\CompilerInterface; |
|
|
|
|
|
|
14
|
|
|
use Railt\Reflection\Contracts\Definitions\DirectiveDefinition; |
|
|
|
|
|
|
15
|
|
|
use Railt\Reflection\Contracts\Definitions\SchemaDefinition; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class SchemaBuilder |
|
19
|
|
|
* @property SchemaDefinition $reflection |
|
20
|
|
|
*/ |
|
21
|
|
|
class SchemaBuilder extends TypeBuilder |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @return Schema |
|
25
|
|
|
*/ |
|
26
|
|
|
public function build(): Schema |
|
27
|
|
|
{ |
|
28
|
|
|
$schema = \array_merge( |
|
29
|
|
|
$this->buildQuery(), |
|
30
|
|
|
$this->buildMutation(), |
|
31
|
|
|
$this->buildSubscription(), |
|
32
|
|
|
$this->buildDirectives() |
|
33
|
|
|
); |
|
34
|
|
|
|
|
35
|
|
|
return new Schema($schema); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return array |
|
40
|
|
|
*/ |
|
41
|
|
|
private function buildQuery(): array |
|
42
|
|
|
{ |
|
43
|
|
|
$query = $this->reflection->getQuery(); |
|
44
|
|
|
|
|
45
|
|
|
return [ |
|
46
|
|
|
'query' => $this->load($query), |
|
47
|
|
|
]; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return array |
|
52
|
|
|
*/ |
|
53
|
|
|
private function buildMutation(): array |
|
54
|
|
|
{ |
|
55
|
|
|
if ($this->reflection->hasMutation()) { |
|
56
|
|
|
$mutation = $this->reflection->getMutation(); |
|
57
|
|
|
|
|
58
|
|
|
return [ |
|
59
|
|
|
'mutation' => $this->load($mutation), |
|
60
|
|
|
]; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return []; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return array |
|
68
|
|
|
*/ |
|
69
|
|
|
private function buildSubscription(): array |
|
70
|
|
|
{ |
|
71
|
|
|
if ($this->reflection->hasSubscription()) { |
|
72
|
|
|
$subscription = $this->reflection->getSubscription(); |
|
73
|
|
|
|
|
74
|
|
|
return [ |
|
75
|
|
|
'subscription' => $this->load($subscription), |
|
76
|
|
|
]; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return []; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return array |
|
84
|
|
|
*/ |
|
85
|
|
|
private function buildDirectives(): array |
|
86
|
|
|
{ |
|
87
|
|
|
/** @var CompilerInterface $compiler */ |
|
88
|
|
|
$compiler = $this->getRegistry()->getContainer()->make(CompilerInterface::class); |
|
89
|
|
|
|
|
90
|
|
|
$result = []; |
|
91
|
|
|
|
|
92
|
|
|
/** @var DirectiveDefinition $directive */ |
|
93
|
|
|
foreach ($compiler->only(DirectiveDefinition::class) as $directive) { |
|
94
|
|
|
if ($directive->isAllowedForQueries()) { |
|
95
|
|
|
$result[] = $this->load($directive); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
return [ |
|
100
|
|
|
'directives' => $result, |
|
101
|
|
|
]; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths