src/Defer/DeferrableDirective.php
protected function shouldDefer(TypeNode $fieldType, ResolveInfo $resolveInfo): bool
    {
        if (strtolower($resolveInfo->operation->operation) === 'mutation') {
            return false;
        }

        foreach ($resolveInfo->fieldNodes as $fieldNode) {
            $deferDirective = ASTHelper::directiveDefinition($fieldNode, 'defer');

            if (! $deferDirective) {
                return false;
            }

            if (! ASTHelper::directiveArgValue($deferDirective, 'if', true)) {
                return false;
            }

            $skipDirective = ASTHelper::directiveDefinition($fieldNode, 'skip');
            $includeDirective = ASTHelper::directiveDefinition($fieldNode, 'include');

            $shouldSkip = $skipDirective
                ? ASTHelper::directiveArgValue($skipDirective, 'if', false)
                : false;
            $shouldInclude = $includeDirective
                ? ASTHelper::directiveArgValue($includeDirective, 'if', false)
                : false;

            if ($shouldSkip || $shouldInclude) {
                return false;
            }
        }

        if ($fieldType instanceof NonNullTypeNode) {
            throw new ParseClientException('The @defer directive cannot be placed on a Non-Nullable field.');
        }

        return true;
    }
protected function shouldDefer(TypeNode $fieldType, ResolveInfo $resolveInfo): bool
    {
        if (strtolower($resolveInfo->operation->operation) === 'mutation') {
            return false;
        }

        foreach ($resolveInfo->fieldNodes as $fieldNode) {
            $deferDirective = ASTHelper::directiveDefinition($fieldNode, 'defer');

            if (! $deferDirective) {
                return false;
            }

            if (! ASTHelper::directiveArgValue($deferDirective, 'if', true)) {
                return false;
            }

            $skipDirective = ASTHelper::directiveDefinition($fieldNode, 'skip');
            $includeDirective = ASTHelper::directiveDefinition($fieldNode, 'include');

            $shouldSkip = $skipDirective
                ? ASTHelper::directiveArgValue($skipDirective, 'if', false)
                : false;
            $shouldInclude = $includeDirective
                ? ASTHelper::directiveArgValue($includeDirective, 'if', false)
                : false;

            if ($shouldSkip || $shouldInclude) {
                return false;
            }
        }

        if ($fieldType instanceof NonNullTypeNode) {
            throw new ParseClientException('The @defer directive cannot be placed on a Non-Nullable field.');
        }

        return true;
    }
protected function shouldDefer ( TypeNode $ fieldType , ResolveInfo $ resolveInfo ) : bool { if ( strtolower ( $ resolveInfo -> operation -> operation ) === 'mutation' ) { return false ; } foreach ( $ resolveInfo -> fieldNodes as $ fieldNode ) { $ deferDirective = ASTHelper :: directiveDefinition ( $ fieldNode , 'defer' ) ; if ( ! $ deferDirective ) { return false ; } if ( ! ASTHelper :: directiveArgValue ( $ deferDirective , 'if' , true ) ) { return false ; } $ skipDirective = ASTHelper :: directiveDefinition ( $ fieldNode , 'skip' ) ; $ includeDirective = ASTHelper :: directiveDefinition ( $ fieldNode , 'include' ) ; $ shouldSkip = $ skipDirective ? ASTHelper :: directiveArgValue ( $ skipDirective , 'if' , false ) : false ; $ shouldInclude = $ includeDirective ? ASTHelper :: directiveArgValue ( $ includeDirective , 'if' , false ) : false ; if ( $ shouldSkip || $ shouldInclude ) { return false ; } } if ( $ fieldType instanceof NonNullTypeNode ) { throw new ParseClientException ( 'The @defer directive cannot be placed on a Non-Nullable field.' ) ; } return true ; }
Determine if field should be deferred.

@param  \GraphQL\Language\AST\TypeNode  $fieldType
@param  \GraphQL\Type\Definition\ResolveInfo  $resolveInfo
@return bool

@throws \Nuwave\Lighthouse\Exceptions\ParseClientException
Determine if field should be deferred .