From e1178c78b733048e789db790687b923a0a8af3ff Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Sun, 1 Dec 2024 16:21:59 +0100 Subject: [PATCH] fix ci for lower deps --- src/GraphQL.php | 7 +++++-- tests/Unit/Schema/Directives/ComplexityDirectiveTest.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/GraphQL.php b/src/GraphQL.php index 66feba788..10edfd30c 100644 --- a/src/GraphQL.php +++ b/src/GraphQL.php @@ -157,8 +157,11 @@ public function executeParsedQueryRaw( ); $queryComplexityRule = $validationRules[QueryComplexity::class] ?? null; - assert($queryComplexityRule instanceof QueryComplexity || $queryComplexityRule === null); - $queryComplexity = $queryComplexityRule?->getQueryComplexity(); + $queryComplexity = $queryComplexityRule instanceof QueryComplexity + // TODO remove this check when updating the required version of webonyx/graphql-php + && method_exists($queryComplexityRule, 'getQueryComplexity') + ? $queryComplexityRule->getQueryComplexity() + : null; /** @var array<\Nuwave\Lighthouse\Execution\ExtensionsResponse|null> $extensionsResponses */ $extensionsResponses = (array) $this->eventDispatcher->dispatch( diff --git a/tests/Unit/Schema/Directives/ComplexityDirectiveTest.php b/tests/Unit/Schema/Directives/ComplexityDirectiveTest.php index 22719f000..418349a44 100644 --- a/tests/Unit/Schema/Directives/ComplexityDirectiveTest.php +++ b/tests/Unit/Schema/Directives/ComplexityDirectiveTest.php @@ -46,8 +46,11 @@ public function testDefaultComplexity(): void $this->assertCount(1, $events); - $event = $events[0]; - $this->assertSame(2, $event->queryComplexity); + // TODO remove this check when updating the required version of webonyx/graphql-php + if (method_exists(QueryComplexity::class, 'getQueryComplexity')) { + $event = $events[0]; + $this->assertSame(2, $event->queryComplexity); + } } public function testKnowsPagination(): void