Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia authored Mar 1, 2024
1 parent b8dd562 commit 001126d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ You can find and compare releases at the [GitHub release page](https://github.co

## Unreleased

- Merge directives from Scalar/Enum/Type/Input/Interface extension node into target node.
### Added

- Merge directives from Scalar/Enum/Type/Input/Interface extension node into target node https://github.com/nuwave/lighthouse/pull/2512

## v6.33.4

Expand Down
5 changes: 4 additions & 1 deletion src/Schema/AST/ASTBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ protected function missingBaseDefinition(string $typeName, ObjectTypeExtensionNo
return "Could not find a base definition {$typeName} of kind {$typeExtension->kind} to extend.";
}

protected function assertExtensionMatchesDefinition(ObjectTypeExtensionNode|InputObjectTypeExtensionNode|InterfaceTypeExtensionNode|ScalarTypeExtensionNode|EnumTypeExtensionNode|UnionTypeExtensionNode $extension, ObjectTypeDefinitionNode|InputObjectTypeDefinitionNode|InterfaceTypeDefinitionNode|ScalarTypeDefinitionNode|EnumTypeDefinitionNode|UnionTypeDefinitionNode $definition): void
protected function assertExtensionMatchesDefinition(
ObjectTypeExtensionNode|InputObjectTypeExtensionNode|InterfaceTypeExtensionNode|ScalarTypeExtensionNode|EnumTypeExtensionNode|UnionTypeExtensionNode $extension,
ObjectTypeDefinitionNode|InputObjectTypeDefinitionNode|InterfaceTypeDefinitionNode|ScalarTypeDefinitionNode|EnumTypeDefinitionNode|UnionTypeDefinitionNode $definition,
): void
{
if (static::EXTENSION_TO_DEFINITION_CLASS[$extension::class] !== $definition::class) {
throw new DefinitionException("The type extension {$extension->name->value} of kind {$extension->kind} can not extend a definition of kind {$definition->kind}.");
Expand Down
14 changes: 6 additions & 8 deletions tests/Unit/Schema/AST/ASTBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
use Nuwave\Lighthouse\Schema\RootType;
use Tests\TestCase;

use function assert;

final class ASTBuilderTest extends TestCase
{
protected ASTBuilder $astBuilder;
Expand Down Expand Up @@ -59,7 +57,7 @@ public function testMergeTypeExtensionDirectives(): void
$directive = new class() extends BaseDirective {
public static function definition(): string
{
return /** @lang GraphQL */ 'directive @foo on OBJECT';
return /** @lang GraphQL */ 'directive @foo repeatable on OBJECT';
}
};

Expand Down Expand Up @@ -144,7 +142,7 @@ public function testMergeInputExtensionDirectives(): void
$directive = new class() extends BaseDirective {
public static function definition(): string
{
return /** @lang GraphQL */ 'directive @foo on INPUT_OBJECT';
return /** @lang GraphQL */ 'directive @foo repeatable on INPUT_OBJECT';
}
};

Expand Down Expand Up @@ -196,7 +194,7 @@ public function testMergeInterfaceExtensionDirectives(): void
$directive = new class() extends BaseDirective {
public static function definition(): string
{
return /** @lang GraphQL */ 'directive @foo on INTERFACE';
return /** @lang GraphQL */ 'directive @foo repeatable on INTERFACE';
}
};

Expand Down Expand Up @@ -225,7 +223,7 @@ public function testMergeScalarExtensionDirectives(): void
$directive = new class() extends BaseDirective {
public static function definition(): string
{
return /** @lang GraphQL */ 'directive @foo on SCALAR';
return /** @lang GraphQL */ 'directive @foo repeatable on SCALAR';
}
};

Expand Down Expand Up @@ -276,7 +274,7 @@ public function testMergeEnumExtensionDirectives(): void
$directive = new class() extends BaseDirective {
public static function definition(): string
{
return /** @lang GraphQL */ 'directive @foo on ENUM';
return /** @lang GraphQL */ 'directive @foo repeatable on ENUM';
}
};

Expand Down Expand Up @@ -327,7 +325,7 @@ public function testDoesNotAllowExtendingUndefinedScalar(): void
$directive = new class() extends BaseDirective {
public static function definition(): string
{
return /** @lang GraphQL */ 'directive @foo on SCALAR';
return /** @lang GraphQL */ 'directive @foo repeatable on SCALAR';
}
};

Expand Down

0 comments on commit 001126d

Please sign in to comment.