Server: use proper batching helper

This commit is contained in:
Vladimir Razuvaev 2017-07-17 23:48:30 +07:00
parent 919cf80240
commit 49208d758d

View File

@ -1,8 +1,6 @@
<?php <?php
namespace GraphQL\Server; namespace GraphQL\Server;
use GraphQL\Error\InvariantViolation;
use GraphQL\Utils\Utils;
use GraphQL\Executor\ExecutionResult; use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Promise\Promise; use GraphQL\Executor\Promise\Promise;
@ -58,13 +56,10 @@ class StandardServer
} }
$this->helper->assertValidRequest($parsedBody); $this->helper->assertValidRequest($parsedBody);
$batched = is_array($parsedBody); if (is_array($parsedBody)) {
return $this->helper->executeBatch($this->config, $parsedBody);
$result = []; } else {
foreach ((array) $parsedBody as $index => $operationParams) { return $this->helper->executeOperation($this->config, $parsedBody);
$result[] = $this->helper->executeOperation($this->config, $operationParams); }
}
return $batched ? $result : $result[0];
} }
} }