1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace TheCodingMachine\Tdbm\GraphQL\Fixtures; |
5
|
|
|
|
6
|
|
|
use TheCodingMachine\Tdbm\GraphQL\Registry\Registry; |
7
|
|
|
use TheCodingMachine\Tdbm\GraphQL\Tests\DAOs\UserDao; |
8
|
|
|
use TheCodingMachine\Tdbm\GraphQL\Tests\GraphQL\UserType; |
9
|
|
|
use Youshido\GraphQL\Config\Schema\SchemaConfig; |
10
|
|
|
use Youshido\GraphQL\Field\InputField; |
11
|
|
|
use Youshido\GraphQl\Relay\Connection\ArrayConnection; |
12
|
|
|
use Youshido\GraphQL\Relay\Connection\Connection; |
13
|
|
|
use Youshido\GraphQL\Relay\Fetcher\CallableFetcher; |
14
|
|
|
use Youshido\GraphQL\Relay\Field\NodeField; |
15
|
|
|
use Youshido\GraphQL\Relay\RelayMutation; |
16
|
|
|
use Youshido\GraphQL\Schema\AbstractSchema; |
17
|
|
|
use Youshido\GraphQL\Type\ListType\ListType; |
18
|
|
|
use Youshido\GraphQL\Type\NonNullType; |
19
|
|
|
use Youshido\GraphQL\Type\Scalar\StringType; |
20
|
|
|
|
21
|
|
|
class TestSchema extends AbstractSchema |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var UserDao |
26
|
|
|
*/ |
27
|
|
|
private $userDao; |
28
|
|
|
/** |
29
|
|
|
* @var Registry |
30
|
|
|
*/ |
31
|
|
|
private $registry; |
32
|
|
|
|
33
|
|
|
public function __construct(Registry $registry, UserDao $userDao, array $config = []) |
34
|
|
|
{ |
35
|
|
|
$this->userDao = $userDao; |
36
|
|
|
$this->registry = $registry; |
37
|
|
|
parent::__construct($config); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function build(SchemaConfig $config) |
41
|
|
|
{ |
42
|
|
|
/*$fetcher = new CallableFetcher( |
|
|
|
|
43
|
|
|
function ($type, $id) { |
44
|
|
|
switch ($type) { |
45
|
|
|
case FactionType::TYPE_KEY: |
46
|
|
|
return TestDataProvider::getFaction($id); |
47
|
|
|
|
48
|
|
|
case |
49
|
|
|
ShipType::TYPE_KEY: |
50
|
|
|
return TestDataProvider::getShip($id); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return null; |
54
|
|
|
}, |
55
|
|
|
function ($object) { |
56
|
|
|
return $object && array_key_exists('ships', $object) ? new FactionType() : new ShipType(); |
57
|
|
|
} |
58
|
|
|
);*/ |
59
|
|
|
|
60
|
|
|
$config->getQuery() |
61
|
|
|
//->addField(new NodeField($fetcher)) |
|
|
|
|
62
|
|
|
->addField('users', [ |
63
|
|
|
'type' => new ListType(new UserType($this->registry)), |
64
|
|
|
'resolve' => function () { |
65
|
|
|
//return TestDataProvider::getFaction('rebels'); |
|
|
|
|
66
|
|
|
return $this->userDao->findAll(); |
67
|
|
|
} |
68
|
|
|
]); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.