|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is a part of graphql-youshido project. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Alexandr Viniychuk <[email protected]> |
|
6
|
|
|
* created: 11/30/15 12:44 AM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Youshido\Tests\DataProvider; |
|
10
|
|
|
|
|
11
|
|
|
use Youshido\GraphQL\Type\Object\AbstractObjectType; |
|
12
|
|
|
use Youshido\GraphQL\Type\Object\ObjectType; |
|
13
|
|
|
use Youshido\GraphQL\Type\Scalar\IntType; |
|
14
|
|
|
use Youshido\GraphQL\Type\Scalar\StringType; |
|
15
|
|
|
use Youshido\GraphQL\Type\NonNullType; |
|
16
|
|
|
|
|
17
|
|
|
class TestObjectType extends AbstractObjectType |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
public function build($config) |
|
21
|
|
|
{ |
|
22
|
|
|
$config |
|
23
|
|
|
->addField('id', new IntType()) |
|
24
|
|
|
->addField('name', new StringType()) |
|
25
|
|
|
->addField('region', new ObjectType([ |
|
26
|
|
|
'name' => 'Region', |
|
27
|
|
|
'fields' => [ |
|
28
|
|
|
'country' => new StringType(), |
|
29
|
|
|
'city' => new StringType() |
|
30
|
|
|
], |
|
31
|
|
|
])) |
|
32
|
|
|
->addField('location', [ |
|
33
|
|
|
'type' => new ObjectType( |
|
34
|
|
|
[ |
|
35
|
|
|
'name' => 'Location', |
|
36
|
|
|
'fields' => [ |
|
37
|
|
|
'address' => new StringType() |
|
38
|
|
|
] |
|
39
|
|
|
] |
|
40
|
|
|
), |
|
41
|
|
|
'args' => [ |
|
42
|
|
|
'noop' => new IntType() |
|
43
|
|
|
], |
|
44
|
|
|
'resolve' => function ($value, $args, $info) { |
|
|
|
|
|
|
45
|
|
|
return ['address' => '1234 Street']; |
|
46
|
|
|
} |
|
47
|
|
|
] |
|
48
|
|
|
) |
|
49
|
|
|
->addField( |
|
50
|
|
|
'echo', [ |
|
51
|
|
|
'type' => new StringType(), |
|
52
|
|
|
'args' => [ |
|
53
|
|
|
'value' => new NonNullType(new StringType()) |
|
54
|
|
|
], |
|
55
|
|
|
'resolve' => function ($value, $args, $info) { |
|
|
|
|
|
|
56
|
|
|
return $args['value']; |
|
57
|
|
|
} |
|
58
|
|
|
] |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getInterfaces() |
|
63
|
|
|
{ |
|
64
|
|
|
return [new TestInterfaceType()]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getData() |
|
68
|
|
|
{ |
|
69
|
|
|
return [ |
|
70
|
|
|
'id' => 1, |
|
71
|
|
|
'name' => 'John' |
|
72
|
|
|
]; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.