GraphQL\Executor\Executor::shouldIncludeNode PHP Method

shouldIncludeNode() private static method

Determines if a field should be included based on the @include and @skip directives, where @skip has higher precedence than @include.
private static shouldIncludeNode ( ExecutionContext $exeContext, $directives ) : boolean
$exeContext ExecutionContext
$directives
return boolean
    private static function shouldIncludeNode(ExecutionContext $exeContext, $directives)
    {
        $skipDirective = Directive::skipDirective();
        $includeDirective = Directive::includeDirective();
        /** @var \GraphQL\Language\AST\DirectiveNode $skipNode */
        $skipNode = $directives ? Utils::find($directives, function (\GraphQL\Language\AST\DirectiveNode $directive) use($skipDirective) {
            return $directive->name->value === $skipDirective->name;
        }) : null;
        if ($skipNode) {
            $argValues = Values::getArgumentValues($skipDirective, $skipNode, $exeContext->variableValues);
            if (isset($argValues['if']) && $argValues['if'] === true) {
                return false;
            }
        }
        /** @var \GraphQL\Language\AST\DirectiveNode $includeNode */
        $includeNode = $directives ? Utils::find($directives, function (\GraphQL\Language\AST\DirectiveNode $directive) use($includeDirective) {
            return $directive->name->value === $includeDirective->name;
        }) : null;
        if ($includeNode) {
            $argValues = Values::getArgumentValues($includeDirective, $includeNode, $exeContext->variableValues);
            if (isset($argValues['if']) && $argValues['if'] === false) {
                return false;
            }
        }
        return true;
    }