From 58f70bb2831ee4a47873c73f5303e941034100f8 Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 4 Apr 2020 14:22:59 +0800 Subject: [PATCH 1/3] Do not override ancestor field directives --- src/Parser/Parser.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Parser/Parser.php b/src/Parser/Parser.php index d3dad3cc..708d5335 100644 --- a/src/Parser/Parser.php +++ b/src/Parser/Parser.php @@ -114,7 +114,10 @@ protected function parseOperation($type = Token::TYPE_QUERY) $this->eatMulti([Token::TYPE_COMMA]); $operation = $this->parseBodyItem($type, true); - $operation->setDirectives($directives); + $operation->setDirectives(array_merge( + $directives, + $operation->getDirectives() + )); $fields[] = $operation; } From 437eb79ca5d6247a5ef51e6bd350d557f1785dbc Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 12 Apr 2020 16:22:11 +0800 Subject: [PATCH 2/3] Added test --- tests/Issues/Issue242/Issue242Test.php | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/Issues/Issue242/Issue242Test.php diff --git a/tests/Issues/Issue242/Issue242Test.php b/tests/Issues/Issue242/Issue242Test.php new file mode 100644 index 00000000..ce853f79 --- /dev/null +++ b/tests/Issues/Issue242/Issue242Test.php @@ -0,0 +1,58 @@ +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); + } +} From e51de8735f6812b9fec6db8051ff7403744d59b9 Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 12 Apr 2020 16:33:21 +0800 Subject: [PATCH 3/3] Fixed namespace --- tests/Issues/Issue242/Issue242Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Issues/Issue242/Issue242Test.php b/tests/Issues/Issue242/Issue242Test.php index ce853f79..f53fb095 100644 --- a/tests/Issues/Issue242/Issue242Test.php +++ b/tests/Issues/Issue242/Issue242Test.php @@ -1,6 +1,6 @@