|
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\FieldDefinition; |
|
13
|
|
|
use Railt\Adapters\Webonyx\FieldResolver; |
|
14
|
|
|
use Railt\Adapters\Webonyx\Registry; |
|
15
|
|
|
use Railt\Http\RequestInterface; |
|
|
|
|
|
|
16
|
|
|
use Railt\Reflection\Contracts\Dependent\Field\HasFields; |
|
|
|
|
|
|
17
|
|
|
use Railt\Reflection\Contracts\Dependent\FieldDefinition as ReflectionField; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @property ReflectionField $reflection |
|
21
|
|
|
*/ |
|
22
|
|
|
class FieldBuilder extends DependentDefinitionBuilder |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @param HasFields $type |
|
26
|
|
|
* @param Registry $registry |
|
27
|
|
|
* @return array |
|
28
|
|
|
* @throws \InvalidArgumentException |
|
29
|
|
|
*/ |
|
30
|
|
|
public static function buildFields(HasFields $type, Registry $registry): array |
|
31
|
|
|
{ |
|
32
|
|
|
$result = []; |
|
33
|
|
|
|
|
34
|
|
|
foreach ($type->getFields() as $field) { |
|
35
|
|
|
$result[$field->getName()] = (new static($field, $registry))->build(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
return $result; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return FieldDefinition |
|
43
|
|
|
* @throws \InvalidArgumentException |
|
44
|
|
|
*/ |
|
45
|
|
|
public function build(): FieldDefinition |
|
46
|
|
|
{ |
|
47
|
|
|
$config = [ |
|
48
|
|
|
'name' => $this->reflection->getName(), |
|
49
|
|
|
'description' => $this->reflection->getDescription(), |
|
50
|
|
|
'type' => $this->buildType(), |
|
51
|
|
|
'args' => ArgumentBuilder::buildArguments($this->reflection, $this->getRegistry()), |
|
52
|
|
|
'resolve' => $this->getResolver(), |
|
53
|
|
|
// complexity |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
if ($this->reflection->isDeprecated()) { |
|
57
|
|
|
$config['deprecationReason'] = $this->reflection->getDeprecationReason(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return FieldDefinition::create($config); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return \Closure|null |
|
65
|
|
|
*/ |
|
66
|
|
|
private function getResolver(): ?\Closure |
|
67
|
|
|
{ |
|
68
|
|
|
/** @var RequestInterface $request */ |
|
69
|
|
|
$request = $this->resolve(RequestInterface::class); |
|
70
|
|
|
|
|
71
|
|
|
/** @var FieldResolver $resolver */ |
|
72
|
|
|
$resolver = $this->resolve(FieldResolver::class); |
|
73
|
|
|
|
|
74
|
|
|
return $resolver->getCallback($request, $this->reflection); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
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