1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Andi\GraphQL\WebonyxType; |
6
|
|
|
|
7
|
|
|
use Andi\GraphQL\InputObjectFieldResolver\InputObjectFieldResolverInterface; |
8
|
|
|
use Andi\GraphQL\Type\DynamicObjectTypeInterface; |
9
|
|
|
use GraphQL\Type\Definition as Webonyx; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @see Webonyx\InputObjectType |
13
|
|
|
* |
14
|
|
|
* @phpstan-import-type InputObjectConfig from Webonyx\InputObjectType |
15
|
|
|
*/ |
16
|
|
|
class InputObjectType extends Webonyx\InputObjectType implements DynamicObjectTypeInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var callable|iterable |
20
|
|
|
*/ |
21
|
|
|
private readonly mixed $nativeFields; |
22
|
|
|
|
23
|
|
|
private array $additionalFields = []; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param InputObjectConfig $config |
|
|
|
|
27
|
|
|
* @param InputObjectFieldResolverInterface $inputObjectFieldResolver |
28
|
|
|
*/ |
29
|
|
|
public function __construct( |
30
|
|
|
array $config, |
31
|
|
|
private readonly InputObjectFieldResolverInterface $inputObjectFieldResolver, |
32
|
|
|
) { |
33
|
|
|
if (isset($config['fields'])) { |
34
|
|
|
$this->nativeFields = $config['fields']; |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
$config['fields'] = $this->extractFields(...); |
38
|
|
|
|
39
|
|
|
parent::__construct($config); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function addAdditionalField(mixed $field): static |
43
|
|
|
{ |
44
|
|
|
$this->additionalFields[] = $field; |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
private function extractFields(): iterable |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
/** @psalm-suppress RedundantPropertyInitializationCheck */ |
52
|
|
|
if (isset($this->nativeFields)) { |
53
|
|
|
$fields = \is_callable($this->nativeFields) |
54
|
|
|
? \call_user_func($this->nativeFields) |
55
|
|
|
: $this->nativeFields; |
56
|
|
|
|
57
|
|
|
if (\is_iterable($fields)) { |
58
|
|
|
foreach ($fields as $field) { |
59
|
|
|
yield $this->inputObjectFieldResolver->resolve($field); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
foreach ($this->additionalFields as $field) { |
65
|
|
|
yield $this->inputObjectFieldResolver->resolve($field); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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