1
<?php
2

3
namespace Nuwave\Lighthouse\Schema\Values;
4

5
use GraphQL\Language\AST\TypeDefinitionNode;
6

7
class TypeValue
8
{
9
    /**
10
     * Current GraphQL type.
11
     *
12
     * @var \GraphQL\Type\Definition\Type
13
     */
14
    protected $type;
15

16
    /**
17
     * The underlying type definition node.
18
     *
19
     * @var \GraphQL\Language\AST\TypeDefinitionNode
20
     */
21
    protected $typeDefinition;
22

23
    /**
24
     * Cache key for this type.
25
     *
26
     * @var string|null
27
     */
28
    protected $cacheKey;
29

30 1
    public function __construct(TypeDefinitionNode $typeDefinition)
31
    {
32 1
        $this->typeDefinition = $typeDefinition;
33
    }
34

35
    /**
36
     * Get the name of the node.
37
     */
38 1
    public function getTypeDefinitionName(): string
39
    {
40 1
        return data_get($this->getTypeDefinition(), 'name.value');
41
    }
42

43
    /**
44
     * Get the underlying type definition.
45
     */
46 1
    public function getTypeDefinition(): TypeDefinitionNode
47
    {
48 1
        return $this->typeDefinition;
49
    }
50

51
    /**
52
     * Get node's cache key.
53
     */
54 1
    public function getCacheKey(): ?string
55
    {
56 1
        return $this->cacheKey;
57
    }
58

59
    /**
60
     * Set node cache key.
61
     *
62
     * @return $this
63
     */
64 1
    public function setCacheKey(string $key = null): self
65
    {
66 1
        $this->cacheKey = $key;
67

68 1
        return $this;
69
    }
70
}

Read our documentation on viewing source code .

Loading