|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Youshido\Tests\Issues\Issue116Test; |
|
4
|
|
|
|
|
5
|
|
|
use Youshido\GraphQL\Execution\Processor; |
|
6
|
|
|
use Youshido\GraphQL\Schema\Schema; |
|
7
|
|
|
use Youshido\GraphQL\Type\InputObject\InputObjectType; |
|
8
|
|
|
use Youshido\GraphQL\Type\ListType\ListType; |
|
9
|
|
|
use Youshido\GraphQL\Type\NonNullType; |
|
10
|
|
|
use Youshido\GraphQL\Type\Object\ObjectType; |
|
11
|
|
|
use Youshido\GraphQL\Type\Scalar\IdType; |
|
12
|
|
|
use Youshido\GraphQL\Type\Scalar\IntType; |
|
13
|
|
|
use Youshido\GraphQL\Type\Scalar\StringType; |
|
14
|
|
|
|
|
15
|
|
|
class Issue131Test extends \PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
public function testInternalVariableArgument() |
|
19
|
|
|
{ |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
$schema = new Schema([ |
|
23
|
|
|
'query' => new ObjectType([ |
|
24
|
|
|
'name' => 'RootQuery', |
|
25
|
|
|
'fields' => [ |
|
26
|
|
|
'hello' => new StringType(), |
|
27
|
|
|
] |
|
28
|
|
|
]), |
|
29
|
|
|
'mutation' => new ObjectType([ |
|
30
|
|
|
'name' => 'RootMutation', |
|
31
|
|
|
'fields' => [ |
|
32
|
|
|
'createMeeting' => [ |
|
33
|
|
|
'type' => new ObjectType([ |
|
34
|
|
|
'name' => 'Meeting', |
|
35
|
|
|
'fields' => [ |
|
36
|
|
|
'id' => new IdType(), |
|
37
|
|
|
'name' => new StringType(), |
|
38
|
|
|
] |
|
39
|
|
|
]), |
|
40
|
|
|
'args' => [ |
|
41
|
|
|
'name' => new StringType(), |
|
42
|
|
|
'related_beans' => new ListType(new ObjectType([ |
|
43
|
|
|
'name' => 'RelatedBeanInputType', |
|
44
|
|
|
'fields' => [ |
|
45
|
|
|
'id' => new IntType(), |
|
46
|
|
|
'module' => new StringType(), |
|
47
|
|
|
] |
|
48
|
|
|
])) |
|
49
|
|
|
], |
|
50
|
|
|
'resolve' => function ($source, $args) { |
|
51
|
|
|
return [ |
|
52
|
|
|
'id' => '1', |
|
53
|
|
|
'name' => sprintf('Meeting with %d beans', count($args['related_beans'])), |
|
54
|
|
|
]; |
|
55
|
|
|
} |
|
56
|
|
|
] |
|
57
|
|
|
] |
|
58
|
|
|
]) |
|
59
|
|
|
]); |
|
60
|
|
|
$processor = new Processor($schema); |
|
61
|
|
|
$response = $processor->processPayload(' |
|
62
|
|
|
mutation ($related_beans: RelatedBeanInputType) { |
|
63
|
|
|
createMeeting(name: "Meeting 1", related_beans: $related_beans) { |
|
64
|
|
|
id, |
|
65
|
|
|
name |
|
66
|
|
|
} |
|
67
|
|
|
}', |
|
68
|
|
|
[ |
|
69
|
|
|
"related_beans" => [ |
|
70
|
|
|
["module" => "contacts", "id" => "5cc6be5b-fb86-2671-e2c0-55e749882d29"], |
|
71
|
|
|
["module" => "contacts", "id" => "2a135003-3765-af3f-bc54-55e7497e77aa"], |
|
72
|
|
|
|
|
73
|
|
|
] |
|
74
|
|
|
])->getResponseData(); |
|
75
|
|
|
$this->assertEquals(['data' => ['createMeeting' => [ |
|
76
|
|
|
'id' => '1', |
|
77
|
|
|
'name' => 'Meeting with 2 beans' |
|
78
|
|
|
]]], $response); |
|
79
|
|
|
} |
|
80
|
|
|
} |