src/Schema/Factories/DirectiveFactory.php
protected function createSingleDirectiveOfType(Node $node, string $directiveClass): ?Directive
    {
        $directives = $this->createAssociatedDirectivesOfType($node, $directiveClass);

        if ($directives->count() > 1) {
            $directiveNames = $directives->implode(', ');

            throw new DirectiveException(
                "Node [{$node->name->value}] can only have one directive of type [{$directiveClass}] but found [{$directiveNames}]"
            );
        }

        return $directives->first();
    }
protected function createSingleDirectiveOfType(Node $node, string $directiveClass): ?Directive
    {
        $directives = $this->createAssociatedDirectivesOfType($node, $directiveClass);

        if ($directives->count() > 1) {
            $directiveNames = $directives->implode(', ');

            throw new DirectiveException(
                "Node [{$node->name->value}] can only have one directive of type [{$directiveClass}] but found [{$directiveNames}]"
            );
        }

        return $directives->first();
    }
protected function createSingleDirectiveOfType ( Node $ node , string $ directiveClass ) : ? Directive { $ directives = $ this -> createAssociatedDirectivesOfType ( $ node , $ directiveClass ) ; if ( $ directives -> count ( ) > 1 ) { $ directiveNames = $ directives -> implode ( ', ' ) ; throw new DirectiveException ( "Node [{$node->name->value}] can only have one directive of type [{$directiveClass}] but found [{$directiveNames}]" ) ; } return $ directives -> first ( ) ; }
Get a single directive of a type that belongs to an AST node.

Use this for directives types that can only occur once, such as field resolvers.
This throws if more than one such directive is found.

@param  \GraphQL\Language\AST\Node  $node
@param  string  $directiveClass
@return \Nuwave\Lighthouse\Support\Contracts\Directive|null

@throws \Nuwave\Lighthouse\Exceptions\DirectiveException
Get a single directive of a type that belongs to an AST node .