public function testCombinedFields()
{
$schema = new TestEmptySchema();
$interface = new InterfaceType(['name' => 'TestInterface', 'fields' => ['id' => ['type' => new IntType()], 'name' => ['type' => new IntType()]], 'resolveType' => function ($type) {
}]);
$object1 = new ObjectType(['name' => 'Test1', 'fields' => ['id' => ['type' => new IntType()], 'name' => ['type' => new IntType()], 'lastName' => ['type' => new IntType()]], 'interfaces' => [$interface]]);
$object2 = new ObjectType(['name' => 'Test2', 'fields' => ['id' => ['type' => new IntType()], 'name' => ['type' => new IntType()], 'thirdName' => ['type' => new IntType()]], 'interfaces' => [$interface]]);
$unionType = new UnionType(['name' => 'UnionType', 'types' => [$object1, $object2], 'resolveType' => function () {
}]);
$schema->addQueryField(new Field(['name' => 'union', 'type' => $unionType, 'args' => ['id' => ['type' => TypeMap::TYPE_INT]], 'resolve' => function () {
return ['id' => 1, 'name' => 'Alex'];
}]));
$schema->addMutationField(new Field(['name' => 'mutation', 'type' => $unionType, 'args' => ['type' => new EnumType(['name' => 'MutationType', 'values' => [['name' => 'Type1', 'value' => 'type_1'], ['name' => 'Type2', 'value' => 'type_2']]])], 'resolve' => function () {
return null;
}]));
$processor = new Processor($schema);
$processor->processPayload($this->introspectionQuery);
$responseData = $processor->getResponseData();
/** strange that this test got broken after I fixed the field resolve behavior */
$this->assertArrayNotHasKey('errors', $responseData);
}