Skip to content

Commit 5343a45

Browse files
committed
MC-36456: union implementation
1 parent 7ca421d commit 5343a45

File tree

2 files changed

+14
-3
lines changed
  • lib/internal/Magento/Framework

2 files changed

+14
-3
lines changed

lib/internal/Magento/Framework/GraphQl/Config/Element/Type.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ public function getFields() : array
7373
/**
7474
* Get interfaces the type implements, if any. Return an empty array if none are configured.
7575
*
76-
* @return string[]
76+
* Example return array(
77+
* array(
78+
* 'interface' => 'SomeDefinedTypeInterface',
79+
* 'copyFields' => true
80+
* ),
81+
* ...
82+
* ),
83+
*
84+
* @return array
7785
*/
7886
public function getInterfaces() : array
7987
{

lib/internal/Magento/Framework/GraphQlSchemaStitching/GraphQlReader/Reader/UnionType.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,21 @@ public function read(\GraphQL\Type\Definition\Type $typeMeta): array
5757
{
5858
if ($typeMeta instanceof \GraphQL\Type\Definition\UnionType) {
5959
$typeName = $typeMeta->name;
60-
$types = $typeMeta->getTypes();
6160
$result = [
6261
'name' => $typeName,
6362
'type' => self::GRAPHQL_UNION,
64-
'types' => $types,
63+
'types' => [],
6564
];
6665

6766
$unionTypeResolver = $this->getUnionTypeResolver($typeMeta);
6867
if (!empty($unionTypeResolver)) {
6968
$result['typeResolver'] = $unionTypeResolver;
7069
}
7170

71+
foreach ($typeMeta->getTypes() as $type) {
72+
$result['types'][] = $type->name;
73+
}
74+
7275
if ($this->docReader->read($typeMeta->astNode->directives)) {
7376
$result['description'] = $this->docReader->read($typeMeta->astNode->directives);
7477
}

0 commit comments

Comments
 (0)