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\Definition\Directive; |
13
|
|
|
use GraphQL\Type\Definition\DirectiveLocation; |
14
|
|
|
use Railt\Reflection\Contracts\Definitions\Directive\Location; |
|
|
|
|
15
|
|
|
use Railt\Reflection\Contracts\Definitions\DirectiveDefinition; |
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @property DirectiveDefinition $reflection |
19
|
|
|
*/ |
20
|
|
|
class DirectiveBuilder extends TypeBuilder |
21
|
|
|
{ |
22
|
|
|
private const LOCATION_MAPPINGS = [ |
23
|
|
|
Location::TARGET_QUERY => DirectiveLocation::QUERY, |
24
|
|
|
Location::TARGET_MUTATION => DirectiveLocation::MUTATION, |
25
|
|
|
Location::TARGET_SUBSCRIPTION => DirectiveLocation::SUBSCRIPTION, |
26
|
|
|
Location::TARGET_FIELD => DirectiveLocation::FIELD, |
27
|
|
|
Location::TARGET_FRAGMENT_DEFINITION => DirectiveLocation::FRAGMENT_DEFINITION, |
28
|
|
|
Location::TARGET_FRAGMENT_SPREAD => DirectiveLocation::FRAGMENT_SPREAD, |
29
|
|
|
Location::TARGET_INLINE_FRAGMENT => DirectiveLocation::INLINE_FRAGMENT, |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return Directive |
34
|
|
|
*/ |
35
|
|
|
public function build(): Directive |
36
|
|
|
{ |
37
|
|
|
return new Directive([ |
38
|
|
|
'name' => $this->reflection->getName(), |
39
|
|
|
'description' => $this->reflection->getDescription(), |
40
|
|
|
'locations' => $this->getLocations(), |
41
|
|
|
'args' => [], |
42
|
|
|
]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* TODO Arguments resolve |
47
|
|
|
* |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
private function getArguments(): array |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
return []; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
private function getLocations(): array |
59
|
|
|
{ |
60
|
|
|
$result = []; |
61
|
|
|
|
62
|
|
|
foreach ($this->reflection->getLocations() as $location) { |
63
|
|
|
if (\array_key_exists($location, self::LOCATION_MAPPINGS)) { |
64
|
|
|
$result[] = self::LOCATION_MAPPINGS[$location]; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $result; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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