1
<?php
2

3
namespace Nuwave\Lighthouse\Schema\Directives;
4

5
use Nuwave\Lighthouse\Execution\Arguments\ArgumentSet;
6
use Nuwave\Lighthouse\Execution\Arguments\ResolveNested;
7
use Nuwave\Lighthouse\Support\Contracts\ArgResolver;
8
use Nuwave\Lighthouse\Support\Utils;
9

10
class NestDirective extends BaseDirective implements ArgResolver
11
{
12 1
    public static function definition(): string
13
    {
14
        return /** @lang GraphQL */ <<<'GRAPHQL'
15 1
"""
16
A no-op nested arg resolver that delegates all calls
17
to the ArgResolver directives attached to the children.
18
"""
19
directive @nest on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
20
GRAPHQL;
21
    }
22

23
    /**
24
     * Delegate to nested arg resolvers.
25
     *
26
     * @param  mixed  $root  The result of the parent resolver.
27
     * @param  \Nuwave\Lighthouse\Execution\Arguments\ArgumentSet|array<\Nuwave\Lighthouse\Execution\Arguments\ArgumentSet>  $args  The slice of arguments that belongs to this nested resolver.
28
     */
29 1
    public function __invoke($root, $args)
30
    {
31 1
        $resolveNested = new ResolveNested();
32

33 1
        return Utils::applyEach(
34
            static function (ArgumentSet $argumentSet) use ($resolveNested, $root) {
35 1
                return $resolveNested($root, $argumentSet);
36
            },
37 1
            $args
38
        );
39
    }
40
}

Read our documentation on viewing source code .

Loading