TASK: Allow UnionType extensions

This commit is contained in:
Torsten Blindert 2018-10-01 19:45:48 +02:00
parent 1dc2b939cb
commit 0c33cfa88f

View File

@ -6,6 +6,7 @@ namespace GraphQL\Type\Definition;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\UnionTypeDefinitionNode; use GraphQL\Language\AST\UnionTypeDefinitionNode;
use GraphQL\Language\AST\UnionTypeExtensionNode;
use GraphQL\Utils\Utils; use GraphQL\Utils\Utils;
use function call_user_func; use function call_user_func;
use function is_array; use function is_array;
@ -27,6 +28,9 @@ class UnionType extends Type implements AbstractType, OutputType, CompositeType,
/** @var ObjectType[] */ /** @var ObjectType[] */
private $possibleTypeNames; private $possibleTypeNames;
/** @var UnionTypeExtensionNode[] */
public $extensionASTNodes;
public function __construct($config) public function __construct($config)
{ {
if (! isset($config['name'])) { if (! isset($config['name'])) {
@ -40,10 +44,11 @@ class UnionType extends Type implements AbstractType, OutputType, CompositeType,
* the default implemenation will call `isTypeOf` on each implementing * the default implemenation will call `isTypeOf` on each implementing
* Object type. * Object type.
*/ */
$this->name = $config['name']; $this->name = $config['name'];
$this->description = $config['description'] ?? null; $this->description = $config['description'] ?? null;
$this->astNode = $config['astNode'] ?? null; $this->astNode = $config['astNode'] ?? null;
$this->config = $config; $this->extensionASTNodes = $config['extensionASTNodes'] ?? null;
$this->config = $config;
} }
/** /**