-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathIssue242Test.php
More file actions
58 lines (55 loc) · 1.95 KB
/
Copy pathIssue242Test.php
File metadata and controls
58 lines (55 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Youshido\Tests\Issue242;
use PHPUnit\Framework\TestCase;
use Youshido\GraphQL\Parser\Parser;
use Youshido\GraphQL\Parser\Location;
use Youshido\GraphQL\Parser\Ast\Field;
use Youshido\GraphQL\Parser\Ast\Query;
use Youshido\GraphQL\Parser\Ast\Argument;
use Youshido\GraphQL\Parser\Ast\Directive;
use Youshido\GraphQL\Parser\Ast\ArgumentValue\Literal;
class Issue242Test extends TestCase
{
public function testDoNotOverrideFirstLevelQueryDirectives()
{
/**
* Without the patch, the operation query will override the first level
* query directives.
* In this case, directive `@include(if:false)` would be lost
* Please notice: the bug happens only when adding "query" at the beginning:
* query { ... }
* So this query had no issue:
* $payload = '{ user @include(if:false) { name } }';
*/
$payload = 'query { user @include(if:false) { name } }';
$parser = new Parser();
$data = $parser->parse($payload);
$this->assertEquals([
'queries' => [
new Query(
'user',
null,
[],
[
new Field('name', null, [], [], new Location(1, 35)),
],
[
new Directive(
'include',
[
new Argument('if', new Literal(false, new Location(1, 26)), new Location(1, 23)),
],
new Location(1, 15)
),
],
new Location(1, 9)
)
],
'mutations' => [],
'fragments' => [],
'fragmentReferences' => [],
'variables' => [],
'variableReferences' => [],
], $data);
}
}