Skip to content

Commit

Permalink
add success and failing test for root fragments webonyx#785
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Meyer authored and Dominik Meyer committed Mar 19, 2023
1 parent 4ceb094 commit d502246
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Validator/QueryComplexityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, array<string>> */
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 } }';
Expand Down

0 comments on commit d502246

Please sign in to comment.