From ce67672ace1ebcb4284dd9ef381da4e4cd5545a1 Mon Sep 17 00:00:00 2001 From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:03:26 +0400 Subject: [PATCH] fix(graphql): Lighthouse v6.34.0 compatibility (failed tests). --- .../graphql/src/Builder/Directives/SchemaDirective.php | 8 ++++++-- .../DirectiveTest/ScalarOperators.schema.graphql | 3 --- packages/graphql/src/Utils/AstManipulatorTest.php | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/graphql/src/Builder/Directives/SchemaDirective.php b/packages/graphql/src/Builder/Directives/SchemaDirective.php index 04c49a9c6..cb2501522 100644 --- a/packages/graphql/src/Builder/Directives/SchemaDirective.php +++ b/packages/graphql/src/Builder/Directives/SchemaDirective.php @@ -38,8 +38,8 @@ * Modifies the Schema for Directive. * * We are using special scalars to add operators. The directive provides a way - * to add and extend them. Extending is required because Lighthouse doesn't - * support adding directives from extensions nodes yet. + * to add and extend them. Extending is required because Lighthouse (until v6.34.0) + * doesn't support adding directives from extensions nodes yet. * * @see https://github.com/nuwave/lighthouse/issues/2509 * @see https://github.com/nuwave/lighthouse/pull/2512 @@ -72,6 +72,10 @@ public function __invoke(BuildSchemaString $event): string { #[Override] public function manipulateTypeDefinition(DocumentAST &$documentAST, TypeDefinitionNode &$typeDefinition): void { + // todo(graphql): Lighthouse since v6.34.0 merges directives from + // extension nodes except standard types. So the implementation can + // be simplified. + // Apply `extend scalar`. $manipulator = $this->getAstManipulator($documentAST); diff --git a/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.schema.graphql b/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.schema.graphql index b710b8637..77e685fe6 100644 --- a/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.schema.graphql +++ b/packages/graphql/src/SearchBy/Directives/DirectiveTest/ScalarOperators.schema.graphql @@ -38,6 +38,3 @@ extend scalar SearchByOperatorsExtra scalar Mixed @scalar(class: "GraphQL\\Type\\Definition\\StringType") @searchByOperatorEqual - -extend scalar Mixed -@searchByOperatorNotEqual diff --git a/packages/graphql/src/Utils/AstManipulatorTest.php b/packages/graphql/src/Utils/AstManipulatorTest.php index 63d1c18f7..00c1d26a0 100644 --- a/packages/graphql/src/Utils/AstManipulatorTest.php +++ b/packages/graphql/src/Utils/AstManipulatorTest.php @@ -217,7 +217,6 @@ public function testGetDirectives(): void { <<<'GRAPHQL' extend scalar Int @aDirective @bDirective scalar CustomScalar @bDirective @cDirective - extend scalar CustomScalar @aDirective type Query { test(arg: String @aDirective @cDirective): Test @all @bDirective