mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-11 10:09:24 +03:00
Server: moving things around to simplify
This commit is contained in:
parent
08a68d4857
commit
81986145fe
@ -35,14 +35,7 @@ class Helper
|
|||||||
public function executeOperation(ServerConfig $config, OperationParams $op)
|
public function executeOperation(ServerConfig $config, OperationParams $op)
|
||||||
{
|
{
|
||||||
$promiseAdapter = $config->getPromiseAdapter() ?: Executor::getPromiseAdapter();
|
$promiseAdapter = $config->getPromiseAdapter() ?: Executor::getPromiseAdapter();
|
||||||
|
$result = $this->promiseToExecuteOperation($promiseAdapter, $config, $op);
|
||||||
$errors = $this->validateOperationParams($op);
|
|
||||||
|
|
||||||
if (!empty($errors)) {
|
|
||||||
$result = $promiseAdapter->createFulfilled(new ExecutionResult(null, $errors));
|
|
||||||
} else {
|
|
||||||
$result = $this->promiseToExecuteOperation($promiseAdapter, $config, $op);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($promiseAdapter instanceof SyncPromiseAdapter) {
|
if ($promiseAdapter instanceof SyncPromiseAdapter) {
|
||||||
$result = $promiseAdapter->wait($result);
|
$result = $promiseAdapter->wait($result);
|
||||||
@ -65,12 +58,7 @@ class Helper
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($operations as $operation) {
|
foreach ($operations as $operation) {
|
||||||
$errors = $this->validateOperationParams($operation);
|
$result[] = $this->promiseToExecuteOperation($promiseAdapter, $config, $operation);
|
||||||
if (!empty($errors)) {
|
|
||||||
$result[] = $promiseAdapter->createFulfilled(new ExecutionResult(null, $errors));
|
|
||||||
} else {
|
|
||||||
$result[] = $this->promiseToExecuteOperation($promiseAdapter, $config, $operation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $promiseAdapter->all($result);
|
$result = $promiseAdapter->all($result);
|
||||||
@ -91,6 +79,14 @@ class Helper
|
|||||||
private function promiseToExecuteOperation(PromiseAdapter $promiseAdapter, ServerConfig $config, OperationParams $op)
|
private function promiseToExecuteOperation(PromiseAdapter $promiseAdapter, ServerConfig $config, OperationParams $op)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$errors = $this->validateOperationParams($op);
|
||||||
|
|
||||||
|
if (!empty($errors)) {
|
||||||
|
return $promiseAdapter->createFulfilled(
|
||||||
|
new ExecutionResult(null, $errors)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$doc = $op->queryId ? static::loadPersistedQuery($config, $op) : $op->query;
|
$doc = $op->queryId ? static::loadPersistedQuery($config, $op) : $op->query;
|
||||||
|
|
||||||
if (!$doc instanceof DocumentNode) {
|
if (!$doc instanceof DocumentNode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user