forked from thecodingmachine/graphqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractGraphQLElement.php
More file actions
62 lines (53 loc) · 2.01 KB
/
AbstractGraphQLElement.php
File metadata and controls
62 lines (53 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
namespace TheCodingMachine\GraphQLite\Annotations;
/**
* Shared base for every attribute that declares an invokable GraphQL schema element with a
* return type — {@see Query}, {@see Mutation}, {@see Subscription}, and {@see Field}. Each of
* those attributes inherits a GraphQL-level name, an explicit return type override, and a
* schema description from this class.
*/
abstract class AbstractGraphQLElement
{
private string|null $outputType;
private string|null $name;
private string|null $description;
/** @param mixed[] $attributes */
public function __construct(
array $attributes = [],
string|null $name = null,
string|null $outputType = null,
string|null $description = null,
) {
$this->outputType = $outputType ?? $attributes['outputType'] ?? null;
$this->name = $name ?? $attributes['name'] ?? null;
$this->description = $description ?? $attributes['description'] ?? null;
}
/**
* Returns the GraphQL return type for this schema element (as a string).
* The string can represent the FQCN of the type or an entry in the container resolving to the GraphQL type.
*/
public function getOutputType(): string|null
{
return $this->outputType;
}
/**
* Returns the GraphQL name of the query/mutation/subscription/field.
* If not specified, the name of the PHP method is used instead.
*/
public function getName(): string|null
{
return $this->name;
}
/**
* Returns the explicit description for this schema element, or null if none was provided.
*
* A null return means "no explicit description" and the schema builder may fall back to the
* docblock summary (if docblock descriptions are enabled on the SchemaFactory). An explicit
* empty string blocks the docblock fallback and produces an empty description.
*/
public function getDescription(): string|null
{
return $this->description;
}
}