1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Digia\GraphQL\Util; |
4
|
|
|
|
5
|
|
|
use Digia\GraphQL\Error\ValidationException; |
6
|
|
|
use Digia\GraphQL\GraphQL; |
7
|
|
|
use Digia\GraphQL\Language\Node\NodeInterface; |
8
|
|
|
use Digia\GraphQL\Language\Node\TypeNodeInterface; |
9
|
|
|
use Digia\GraphQL\Type\Definition\TypeInterface; |
10
|
|
|
use Digia\GraphQL\Type\SchemaInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @param string $name |
14
|
|
|
* @return string |
15
|
|
|
*/ |
16
|
|
|
function assertInvalidName(string $name): string |
17
|
|
|
{ |
18
|
|
|
return GraphQL::make(NameHelper::class)->assertInvalid($name); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param string $name |
23
|
|
|
* @param null $node |
|
|
|
|
24
|
|
|
* @return ValidationException|null |
25
|
|
|
*/ |
26
|
|
|
function isValidNameError(string $name, $node = null): ?ValidationException |
27
|
|
|
{ |
28
|
|
|
return GraphQL::make(NameHelper::class)->isValidError($name, $node); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param TypeInterface $typeA |
33
|
|
|
* @param TypeInterface $typeB |
34
|
|
|
* @return bool |
35
|
|
|
*/ |
36
|
|
|
function isEqualType(TypeInterface $typeA, TypeInterface $typeB): bool |
37
|
|
|
{ |
38
|
|
|
return GraphQL::make(TypeHelper::class)->isEqualType($typeA, $typeB); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param SchemaInterface $schema |
43
|
|
|
* @param TypeInterface $maybeSubtype |
44
|
|
|
* @param TypeInterface $superType |
45
|
|
|
* @return bool |
46
|
|
|
*/ |
47
|
|
|
function isTypeSubtypeOf(SchemaInterface $schema, TypeInterface $maybeSubtype, TypeInterface $superType): bool |
48
|
|
|
{ |
49
|
|
|
return GraphQL::make(TypeHelper::class)->isTypeSubtypeOf($schema, $maybeSubtype, $superType); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param SchemaInterface $schema |
54
|
|
|
* @param TypeInterface $typeA |
55
|
|
|
* @param TypeInterface $typeB |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
|
|
function doTypesOverlap(SchemaInterface $schema, TypeInterface $typeA, TypeInterface $typeB): bool |
59
|
|
|
{ |
60
|
|
|
return GraphQL::make(TypeHelper::class)->doTypesOverlap($schema, $typeA, $typeB); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param SchemaInterface $schema |
65
|
|
|
* @param TypeNodeInterface $typeNode |
66
|
|
|
* @return TypeInterface|null |
67
|
|
|
*/ |
68
|
|
|
function typeFromAST(SchemaInterface $schema, TypeNodeInterface $typeNode): ?TypeInterface |
69
|
|
|
{ |
70
|
|
|
return GraphQL::make(TypeHelper::class)->fromAST($schema, $typeNode); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param NodeInterface|null $node |
75
|
|
|
* @param TypeInterface $type |
76
|
|
|
* @param array $variables |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
|
|
function valueFromAST(?NodeInterface $node, TypeInterface $type, array $variables = []) |
80
|
|
|
{ |
81
|
|
|
return GraphQL::make(ValueHelper::class)->fromAST($node, $type, $variables); |
82
|
|
|
} |
83
|
|
|
|