From 6f69bde71eddb3d9b77d2a3c880691f83184f31c Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 19 Sep 2024 19:33:44 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Benedikt Franke --- docs/master/performance/query-caching.md | 7 ++++--- src/LighthouseServiceProvider.php | 1 - src/Support/Contracts/ProvidesCacheableValidationRules.php | 4 ++-- tests/Integration/ValidationCachingTest.php | 2 +- tests/Unit/Schema/AST/DocumentASTTest.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/master/performance/query-caching.md b/docs/master/performance/query-caching.md index 313822b3f..08bd9f400 100644 --- a/docs/master/performance/query-caching.md +++ b/docs/master/performance/query-caching.md @@ -17,11 +17,12 @@ APQ is enabled by default, but depends on query caching being enabled. ## Query validation caching -Lighthouse can cache the result of the query validation process as well. It only caches queries without errors. +Lighthouse can cache the result of the query validation process as well. +It only caches queries without errors. `QueryComplexity` validation can not be cached as it is dependent on the query, so it is always executed. -Query validation caching is disabled by default. You can enable it by setting `validation_cache.enable` to `true` in the -configuration in `config/lighthouse.php`. +Query validation caching is disabled by default. +You can enable it by setting `validation_cache.enable` to `true` in `config/lighthouse.php`. ## Testing caveats diff --git a/src/LighthouseServiceProvider.php b/src/LighthouseServiceProvider.php index 28fc6acbe..580cf34ba 100644 --- a/src/LighthouseServiceProvider.php +++ b/src/LighthouseServiceProvider.php @@ -101,7 +101,6 @@ public function provideSubscriptionResolver(FieldValue $fieldValue): \Closure } }); - // $this->app->bind(ProvidesValidationRules::class, ValidationRulesProvider::class); $this->app->bind(ProvidesValidationRules::class, CacheableValidationRulesProvider::class); $this->commands(self::COMMANDS); diff --git a/src/Support/Contracts/ProvidesCacheableValidationRules.php b/src/Support/Contracts/ProvidesCacheableValidationRules.php index 55fe4b415..f0f333b53 100644 --- a/src/Support/Contracts/ProvidesCacheableValidationRules.php +++ b/src/Support/Contracts/ProvidesCacheableValidationRules.php @@ -7,7 +7,7 @@ interface ProvidesCacheableValidationRules extends ProvidesValidationRules /** * A set of rules for the first query validation step. * - * These rules would be executed first and their result would be cached. + * These rules are executed first and their result is cached. * * @return array */ @@ -16,7 +16,7 @@ public function cacheableValidationRules(): array; /** * A set of rules for the second query validation step. * - * These rules would always be executed and not cached. + * These rules are always be executed and not cached. * * Returning `null` enables all available rules. * Empty array skips query validation entirely. diff --git a/tests/Integration/ValidationCachingTest.php b/tests/Integration/ValidationCachingTest.php index d9cd145d1..e347a784a 100644 --- a/tests/Integration/ValidationCachingTest.php +++ b/tests/Integration/ValidationCachingTest.php @@ -9,7 +9,7 @@ use Tests\TestCase; use Tests\Utils\Queries\Foo; -class ValidationCachingTest extends TestCase +final class ValidationCachingTest extends TestCase { public function testEnabled(): void { diff --git a/tests/Unit/Schema/AST/DocumentASTTest.php b/tests/Unit/Schema/AST/DocumentASTTest.php index de7477dc9..c965847a5 100644 --- a/tests/Unit/Schema/AST/DocumentASTTest.php +++ b/tests/Unit/Schema/AST/DocumentASTTest.php @@ -114,6 +114,6 @@ public function testBeSerialized(): void $this->assertInstanceOf(SchemaExtensionNode::class, $schemaExtension); $this->assertInstanceOf(DirectiveNode::class, $schemaExtension->directives[0]); - $this->assertEquals($documentAST->hash, $reserialized->hash); + $this->assertSame($documentAST->hash, $reserialized->hash); } }