Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules
QueryComplexity::directiveExcludesField
Will the given field be executed at all, given the directives placed upon it?
Method of the class: QueryComplexity{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->directiveExcludesField( $node ): bool;
- $node(FieldNode) (required)
- .
QueryComplexity::directiveExcludesField() QueryComplexity::directiveExcludesField code WC 10.9.1
protected function directiveExcludesField(FieldNode $node): bool
{
foreach ($node->directives as $directiveNode) {
if ($directiveNode->name->value === Directive::DEPRECATED_NAME) {
return false;
}
[$errors, $variableValues] = Values::getVariableValues(
$this->context->getSchema(),
$this->variableDefs,
$this->getRawVariableValues()
);
if ($errors !== null && $errors !== []) {
throw new Error(implode("\n\n", array_map(static fn (Error $error): string => $error->getMessage(), $errors)));
}
if ($directiveNode->name->value === Directive::INCLUDE_NAME) {
$includeArguments = Values::getArgumentValues(
Directive::includeDirective(),
$directiveNode,
$variableValues
);
assert(is_bool($includeArguments['if']), 'ensured by query validation');
return ! $includeArguments['if'];
}
if ($directiveNode->name->value === Directive::SKIP_NAME) {
$skipArguments = Values::getArgumentValues(
Directive::skipDirective(),
$directiveNode,
$variableValues
);
assert(is_bool($skipArguments['if']), 'ensured by query validation');
return $skipArguments['if'];
}
}
return false;
}