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

Improved description formatting for cost complexity #618

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Middlewares/CostFieldMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function process(QueryFieldDescriptor $queryFieldDescriptor, FieldHandler

private function buildQueryComment(Cost $costAttribute): string
{
return 'Cost: ' .
return "\nCost: " .
implode(', ', [
'complexity = ' . $costAttribute->complexity,
'multipliers = [' . implode(', ', $costAttribute->multipliers) . ']',
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/QueryComplexityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function testReportsQueryCostInIntrospection(string|null $expectedDescrip
public static function reportsQueryCostInIntrospectionProvider(): iterable
{
yield [
'Cost: complexity = 5, multipliers = [take], defaultMultiplier = 500',
"\nCost: complexity = 5, multipliers = [take], defaultMultiplier = 500",
'Query',
'articles',
];
Expand All @@ -187,15 +187,15 @@ public static function reportsQueryCostInIntrospectionProvider(): iterable
];

yield [
'Cost: complexity = 5, multipliers = [], defaultMultiplier = null',
"\nCost: complexity = 5, multipliers = [], defaultMultiplier = null",
'Post',
'comment',
];

yield [
'Cost: complexity = 3, multipliers = [], defaultMultiplier = null',
"\nCost: complexity = 3, multipliers = [], defaultMultiplier = null",
'Post',
'author',
];
}
}
}
6 changes: 3 additions & 3 deletions tests/Middlewares/CostFieldMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ public function testAddsCostInDescription(string $expectedDescription, Cost $cos
public static function addsCostInDescriptionProvider(): iterable
{
yield [
'Cost: complexity = 1, multipliers = [], defaultMultiplier = null',
"\nCost: complexity = 1, multipliers = [], defaultMultiplier = null",
new Cost(),
];

yield [
'Cost: complexity = 5, multipliers = [take], defaultMultiplier = 500',
"\nCost: complexity = 5, multipliers = [take], defaultMultiplier = 500",
new Cost(complexity: 5, multipliers: ['take'], defaultMultiplier: 500)
];

yield [
'Cost: complexity = 5, multipliers = [take, null], defaultMultiplier = null',
"\nCost: complexity = 5, multipliers = [take, null], defaultMultiplier = null",
new Cost(complexity: 5, multipliers: ['take', 'null'], defaultMultiplier: null)
];
}
Expand Down
Loading