From fd16f94d1955b84de45a01e46d61da81ef1d707b Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Sun, 19 Mar 2023 12:16:34 +0100 Subject: [PATCH] add success and failing test for root fragments #785 --- tests/Validator/QueryComplexityTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Validator/QueryComplexityTest.php b/tests/Validator/QueryComplexityTest.php index 8e453c46d..7e1058f61 100644 --- a/tests/Validator/QueryComplexityTest.php +++ b/tests/Validator/QueryComplexityTest.php @@ -59,6 +59,23 @@ public function testFragmentQueries(): void $this->assertDocumentValidators($query, 2, 3); } + /** + * @dataProvider fragmentQueriesOnRootProvider + */ + public function testFragmentQueriesOnRoot(string $query): void + { + $this->assertDocumentValidators($query, 12, 13); + } + + /** @return array> */ + public function fragmentQueriesOnRootProvider(): array + { + return [ + ['fragment humanFragment on QueryRoot { human { dogs { name } } } query { ...humanFragment }'], // success example + ['query { ...humanFragment } fragment humanFragment on QueryRoot { human { dogs { name } } }'], // failing example, changed order see https://github.com/webonyx/graphql-php/issues/785 + ]; + } + public function testAliasesQueries(): void { $query = 'query MyQuery { thomas: human(name: "Thomas") { firstName } jeremy: human(name: "Jeremy") { firstName } }';