Skip to content

Commit 5e59b9c

Browse files
Autofix
1 parent 73c9774 commit 5e59b9c

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

docs/class-reference.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ static function executeQuery(
7070
?array $variableValues = null,
7171
?string $operationName = null,
7272
?callable $fieldResolver = null,
73-
?array $validationRules = null
73+
?array $validationRules = null,
74+
?GraphQL\Validator\ValidationCache $cache = null
7475
): GraphQL\Executor\ExecutionResult
7576
```
7677

@@ -98,7 +99,8 @@ static function promiseToExecute(
9899
?array $variableValues = null,
99100
?string $operationName = null,
100101
?callable $fieldResolver = null,
101-
?array $validationRules = null
102+
?array $validationRules = null,
103+
?GraphQL\Validator\ValidationCache $cache = null
102104
): GraphQL\Executor\Promise\Promise
103105
```
104106

@@ -1811,7 +1813,8 @@ static function validate(
18111813
GraphQL\Type\Schema $schema,
18121814
GraphQL\Language\AST\DocumentNode $ast,
18131815
?array $rules = null,
1814-
?GraphQL\Utils\TypeInfo $typeInfo = null
1816+
?GraphQL\Utils\TypeInfo $typeInfo = null,
1817+
?GraphQL\Validator\ValidationCache $cache = null
18151818
): array
18161819
```
18171820

src/Validator/ValidationCache.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ interface ValidationCache
1818
*/
1919
public function isValidated(Schema $schema, DocumentNode $ast): bool;
2020

21-
/**
22-
* Cache validation status for this schema/query.
23-
*/
21+
/** Cache validation status for this schema/query. */
2422
public function markValidated(Schema $schema, DocumentNode $ast): void;
25-
}
23+
}

tests/Executor/ValidationWithCacheTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public function testIsValidationCachedWithAdapter(): void
2525
{
2626
$cache = new PsrValidationCacheAdapter(new Psr16Cache(new ArrayAdapter()));
2727

28-
29-
3028
$petType = new InterfaceType([
3129
'name' => 'Pet',
3230
'fields' => [
@@ -82,10 +80,10 @@ public function testIsValidationCachedWithAdapter(): void
8280
}
8381
}';
8482

85-
GraphQL::executeQuery( $schema, $query, null, null, null, null, null, null, $cache)->toArray();
83+
GraphQL::executeQuery($schema, $query, null, null, null, null, null, null, $cache)->toArray();
8684

8785
// TODO: use a spy or something to prove that the validation only happens once
88-
$result = GraphQL::executeQuery( $schema, $query, null, null, null, null, null, null, $cache)->toArray();
86+
$result = GraphQL::executeQuery($schema, $query, null, null, null, null, null, null, $cache)->toArray();
8987

9088
$expected = [
9189
'data' => [

tests/PsrValidationCacheAdapter.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,33 @@
1818
final class PsrValidationCacheAdapter implements ValidationCache
1919
{
2020
private const KEY_PREFIX = 'gql_validation_';
21+
2122
private int $ttl;
23+
2224
private CacheInterface $cache;
2325

2426
public function __construct(
25-
CacheInterface $cache,
27+
CacheInterface $cache,
2628
int $ttlSeconds = 300
2729
) {
2830
$this->ttl = $ttlSeconds;
2931
$this->cache = $cache;
3032
}
3133

32-
/**
33-
* @throws InvalidArgumentException
34-
*/
34+
/** @throws InvalidArgumentException */
3535
public function isValidated(Schema $schema, DocumentNode $ast): bool
3636
{
3737
try {
3838
$key = $this->buildKey($schema, $ast);
39+
3940
/** @phpstan-ignore-next-line */
4041
return $this->cache->has($key);
4142
} catch (\Throwable $e) {
4243
return false;
4344
}
4445
}
4546

46-
/**
47-
* @throws InvalidArgumentException
48-
*/
47+
/** @throws InvalidArgumentException */
4948
public function markValidated(Schema $schema, DocumentNode $ast): void
5049
{
5150
try {

0 commit comments

Comments
 (0)