|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of Railt package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Railt\SDL\Standard\Directives; |
|
11
|
|
|
|
|
12
|
|
|
use Railt\SDL\Base\Definitions\BaseDirective; |
|
13
|
|
|
use Railt\SDL\Contracts\Definitions\Directive\Location; |
|
14
|
|
|
use Railt\SDL\Contracts\Dependent\ArgumentDefinition; |
|
15
|
|
|
use Railt\SDL\Contracts\Document; |
|
16
|
|
|
use Railt\SDL\Standard\Directives\Deprecation\Reason; |
|
17
|
|
|
use Railt\SDL\Standard\StandardType; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class Deprecation |
|
21
|
|
|
* |
|
22
|
|
|
* @see https://github.com/graphql/graphql-js/pull/384 |
|
23
|
|
|
*/ |
|
24
|
|
|
final class Deprecation extends BaseDirective implements StandardType |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Deprecation directive name |
|
28
|
|
|
*/ |
|
29
|
|
|
public const DIRECTIVE_TYPE_NAME = 'deprecated'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Deprecation reason argument |
|
33
|
|
|
*/ |
|
34
|
|
|
public const REASON_ARGUMENT = 'reason'; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Deprecation constructor. |
|
38
|
|
|
* @param Document $document |
|
39
|
|
|
*/ |
|
40
|
283 |
|
public function __construct(Document $document) |
|
41
|
|
|
{ |
|
42
|
283 |
|
$this->document = $document; |
|
43
|
283 |
|
$this->name = self::DIRECTIVE_TYPE_NAME; |
|
44
|
283 |
|
$this->deprecationReason = self::RFC_IMPL_DESCRIPTION; |
|
45
|
283 |
|
$this->locations = Location::TARGET_GRAPHQL_SDL; |
|
46
|
|
|
|
|
47
|
283 |
|
$argument = $this->createReasonArgument(); |
|
48
|
283 |
|
$this->arguments[$argument->getName()] = $argument; |
|
49
|
283 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return ArgumentDefinition |
|
53
|
|
|
*/ |
|
54
|
283 |
|
private function createReasonArgument(): ArgumentDefinition |
|
55
|
|
|
{ |
|
56
|
283 |
|
return new Reason($this->getDocument(), $this); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|