This commit is contained in:
Your Name
2021-07-26 19:46:18 +02:00
parent e7a49138bb
commit aae17f10a6
818 changed files with 70695 additions and 16408 deletions
@@ -9,6 +9,7 @@ use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\NodeKind;
use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\Visitor;
use GraphQL\Language\VisitorOperation;
use GraphQL\Validator\ValidationContext;
use function sprintf;
@@ -26,18 +27,18 @@ class NoUnusedFragments extends ValidationRule
$this->fragmentDefs = [];
return [
NodeKind::OPERATION_DEFINITION => function ($node) {
NodeKind::OPERATION_DEFINITION => function ($node) : VisitorOperation {
$this->operationDefs[] = $node;
return Visitor::skipNode();
},
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $def) {
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $def) : VisitorOperation {
$this->fragmentDefs[] = $def;
return Visitor::skipNode();
},
NodeKind::DOCUMENT => [
'leave' => function () use ($context) {
'leave' => function () use ($context) : void {
$fragmentNameUsed = [];
foreach ($this->operationDefs as $operation) {
@@ -48,7 +49,7 @@ class NoUnusedFragments extends ValidationRule
foreach ($this->fragmentDefs as $fragmentDef) {
$fragName = $fragmentDef->name->value;
if (! empty($fragmentNameUsed[$fragName])) {
if ($fragmentNameUsed[$fragName] ?? false) {
continue;
}