Skip to content

Commit

Permalink
refactor(graphql)!: HandlerDirective::getDirectives() removed (not …
Browse files Browse the repository at this point in the history
…used anymore).
  • Loading branch information
LastDragon-ru committed Aug 15, 2023
1 parent 492e421 commit aacd7b1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
6 changes: 0 additions & 6 deletions packages/graphql/src/Builder/Directives/HandlerDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use Nuwave\Lighthouse\Execution\Arguments\Argument;
use Nuwave\Lighthouse\Execution\Arguments\ArgumentSet;
use Nuwave\Lighthouse\Schema\AST\DocumentAST;
use Nuwave\Lighthouse\Schema\DirectiveLocator;
use Nuwave\Lighthouse\Schema\Directives\BaseDirective;

use function array_map;
Expand All @@ -45,7 +44,6 @@ abstract class HandlerDirective extends BaseDirective implements Handler {

public function __construct(
private ArgumentFactory $factory,
private DirectiveLocator $directives,
) {
// empty
}
Expand All @@ -60,10 +58,6 @@ abstract public static function getScope(): string;
protected function getFactory(): ArgumentFactory {
return $this->factory;
}

protected function getDirectives(): DirectiveLocator {
return $this->directives;
}
// </editor-fold>

// <editor-fold desc="Handle">
Expand Down
4 changes: 1 addition & 3 deletions packages/graphql/src/Builder/Traits/WithBuilderInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
trait WithBuilderInfo {
use WithSource;

abstract protected function getDirectives(): DirectiveLocator;

protected function getFieldArgumentBuilderInfo(
DocumentAST $document,
ObjectTypeDefinitionNode|InterfaceTypeDefinitionNode $type,
Expand All @@ -62,7 +60,7 @@ protected function getFieldArgumentBuilderInfo(

protected function getBuilderInfo(FieldDefinitionNode $field): ?BuilderInfo {
// Provider?
$directives = $this->getDirectives();
$directives = Container::getInstance()->make(DirectiveLocator::class);
$provider = $directives->associated($field)->first(static function (Directive $directive): bool {
return $directive instanceof BuilderInfoProvider;
});
Expand Down
12 changes: 1 addition & 11 deletions packages/graphql/src/Builder/Traits/WithBuilderInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,11 @@ class WithBuilderInfoTest extends TestCase {
public function testGetBuilderInfo(array $expected, Closure $fieldFactory): void {
$directives = $this->app->make(DirectiveLocator::class);
$field = $fieldFactory($directives);
$directive = new class($directives) extends BaseDirective {
$directive = new class() extends BaseDirective {
use WithBuilderInfo {
getBuilderInfo as public;
}

public function __construct(
private DirectiveLocator $directives,
) {
// empty
}

protected function getDirectives(): DirectiveLocator {
return $this->directives;
}

public static function definition(): string {
throw new Exception('should not be called.');
}
Expand Down

0 comments on commit aacd7b1

Please sign in to comment.