Skip to content
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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"psr/simple-cache": "^1.0.1 || ^2 || ^3",
"symfony/cache": "^4.3 || ^5 || ^6 || ^7 || ^8",
"symfony/expression-language": "^4 || ^5 || ^6 || ^7 || ^8",
"webonyx/graphql-php": "^v15.0",
"webonyx/graphql-php": "^v15.38.3",
"kcs/class-finder": "^0.6.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Psr15GraphQLMiddlewareBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use GraphQL\Server\ServerConfig;
use GraphQL\Type\Schema;
use GraphQL\Validator\DocumentValidator;
use GraphQL\Validator\Rules\QueryComplexity;
use GraphQL\Validator\Rules\ValidationRule;
use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\StreamFactory;
Expand All @@ -23,7 +24,6 @@
use TheCodingMachine\GraphQLite\GraphQLRuntimeException;
use TheCodingMachine\GraphQLite\Server\PersistedQuery\CachePersistedQueryLoader;
use TheCodingMachine\GraphQLite\Server\PersistedQuery\NotSupportedPersistedQueryLoader;
use TheCodingMachine\GraphQLite\Validator\Rules\QueryComplexity;

use function class_exists;
use function is_callable;
Expand Down
81 changes: 0 additions & 81 deletions src/Validator/Rules/QueryComplexity.php

This file was deleted.

5 changes: 2 additions & 3 deletions tests/Integration/QueryComplexityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use GraphQL\Validator\Rules\QueryComplexity;
use PHPUnit\Framework\Attributes\DataProvider;
use TheCodingMachine\GraphQLite\Schema;
use TheCodingMachine\GraphQLite\Validator\Rules\QueryComplexity as GraphQLiteQueryComplexity;

class QueryComplexityTest extends IntegrationTestCase
{
Expand Down Expand Up @@ -60,7 +59,7 @@ public function testExceedsAllowedQueryComplexity(): void
$this->assertSame('Max query complexity should be 5 but got 60.', $result->toArray(DebugFlag::RETHROW_UNSAFE_EXCEPTIONS)['errors'][0]['message']);
}

public function testInvalidVariableIsRefusedByTheExecutor(): void
public function testInvalidVariableIsRefusedWithItsLocation(): void
{
$schema = $this->mainContainer->get(Schema::class);
assert($schema instanceof Schema);
Expand All @@ -77,7 +76,7 @@ public function testInvalidVariableIsRefusedByTheExecutor(): void
variableValues: ['take' => 'many'],
validationRules: [
...DocumentValidator::allRules(),
new GraphQLiteQueryComplexity(60),
new QueryComplexity(60),
]
);

Expand Down
162 changes: 0 additions & 162 deletions tests/Validator/Rules/QueryComplexityTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions website/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ sidebar_label: Changelog
reach the schema when `SchemaFactory::setDocblockDescriptionsEnabled(false)` is set.
([#838](https://github.com/thecodingmachine/graphqlite/pull/838)) @oojacoboo
- `Psr15GraphQLMiddlewareBuilder::limitQueryComplexity()` no longer turns invalid variables into a single joined
error without locations. Its rule, `TheCodingMachine\GraphQLite\Validator\Rules\QueryComplexity`, leaves them
to the executor, which refuses each variable with its own located error.
error without locations. GraphQLite now requires `webonyx/graphql-php` 15.38.3, whose `QueryComplexity` rule
reports each invalid variable with its own located error.
([#839](https://github.com/thecodingmachine/graphqlite/pull/839)) @oojacoboo

## >8.0.0
Expand Down
6 changes: 0 additions & 6 deletions website/docs/operation-complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,5 @@ $builder = new Psr15GraphQLMiddlewareBuilder($schema);
$builder->limitQueryComplexity(1000);
```

`limitQueryComplexity()` registers GraphQLite's `TheCodingMachine\GraphQLite\Validator\Rules\QueryComplexity`,
a subclass of webonyx's `QueryComplexity` rule. Pricing fields by their arguments coerces the operation's variables
during validation; when a variable is invalid, the operation is refused by the executor with one error per variable,
including its location, rather than a single joined validation error. If you register the rule yourself with
`addValidationRule()`, prefer this class over webonyx's.

Beware that introspection queries would also be limited in complexity. A full introspection
query sits at around `107` points, so we recommend a minimum of `150` for query complexity limit.
Loading