public function testCorrectFieldOrderingDespiteExecutionOrder()
{
Executor::setPromiseAdapter(new ReactPromiseAdapter());
$doc = '{
a,
b,
c,
d,
e
}';
$data = ['a' => function () {
return 'a';
}, 'b' => function () {
return new Promise(function (callable $resolve) {
return $resolve('b');
});
}, 'c' => function () {
return 'c';
}, 'd' => function () {
return new Promise(function (callable $resolve) {
return $resolve('d');
});
}, 'e' => function () {
return 'e';
}];
$ast = Parser::parse($doc);
$queryType = new ObjectType(['name' => 'DeepDataType', 'fields' => ['a' => ['type' => Type::string()], 'b' => ['type' => Type::string()], 'c' => ['type' => Type::string()], 'd' => ['type' => Type::string()], 'e' => ['type' => Type::string()]]]);
$schema = new Schema(['query' => $queryType]);
$expected = ['data' => ['a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', 'e' => 'e']];
$this->assertEquals($expected, self::awaitPromise(Executor::execute($schema, $ast, $data)));
}