Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate query complexity with fragments correctly independent of order #1668

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/Validator/QueryComplexityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ public function testFragmentQueries(): void
$this->assertDocumentValidators($query, 2, 3);
}

/** @dataProvider fragmentQueriesOnRootProvider */
public function testFragmentQueriesOnRoot(string $query): void
{
$this->assertDocumentValidators($query, 12, 13);
}

/** @return iterable<array<string>> */
public function fragmentQueriesOnRootProvider(): iterable
{
yield ['fragment humanFragment on QueryRoot { human { dogs { name } } } query { ...humanFragment }']; // success example
yield ['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
Loading