You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The newly supported union is the cause of this issue in the parseTypes function.
The regex is finding the type of union CompanyStructureEntity but its also grabbing the item below it and including it as part of its schema content, which means CompanyStructureEntity contains the schema for itself as well as CompanyStructureItem , this means I never have a $knownTypes['CompanyStructureItem'] to work with which means it is a missing dependency.
```
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
/** @var Magento\Framework\GraphQlSchemaStitching\GraphQlReader $graphqlReader */
$graphqlReader = $obj->get(Magento\Framework\GraphQlSchemaStitching\GraphQlReader::class);
$reflector = new ReflectionObject($graphqlReader);
$method = $reflector->getMethod('parseTypes');
$method->setAccessible(true);
$broken =
'type IsCompanyEmailAvailableOutput @doc(description: "Contains the response of a company email validation query") {
is_email_available: Boolean! @doc(description: "A value of `true` indicates the email address can be used to create a company")
}
union CompanyStructureEntity @typeResolver(class: "Magento\\CompanyGraphQl\\Model\\Resolver\\StructureEntityTypeResolver") = CompanyTeam | Customer
type CompanyStructureItem @doc(description: "Defines an individual node in the company structure") {
id: ID! @doc(description: "The unique ID for a `CompanyStructureItem` object")
parent_id: ID @doc(description: "The ID of the parent item in the company hierarchy")
entity: CompanyStructureEntity @doc(description: "A union of `CompanyTeam` and `Customer` objects")
}
type CompanyStructure @doc(description: "Contains an array of the individual nodes that comprise the company structure") {
items: [CompanyStructureItem] @doc(description: "An array of elements in a company structure")
}';
$result = $method->invoke($graphqlReader, $broken);
echo "Got the following types" . PHP_EOL;
echo implode(PHP_EOL, array_keys($result)) . PHP_EOL;
echo "The values for the union actually contains CompanyStructureItem which is why the initial approach works any mine does not" . PHP_EOL;
echo $result['CompanyStructureEntity'] . PHP_EOL;
```
0 commit comments