Skip to content

Commit 8198614

Browse files
committed
Server: moving things around to simplify
1 parent 08a68d4 commit 8198614

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Server/Helper.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,7 @@ class Helper
3535
public function executeOperation(ServerConfig $config, OperationParams $op)
3636
{
3737
$promiseAdapter = $config->getPromiseAdapter() ?: Executor::getPromiseAdapter();
38-
39-
$errors = $this->validateOperationParams($op);
40-
41-
if (!empty($errors)) {
42-
$result = $promiseAdapter->createFulfilled(new ExecutionResult(null, $errors));
43-
} else {
44-
$result = $this->promiseToExecuteOperation($promiseAdapter, $config, $op);
45-
}
38+
$result = $this->promiseToExecuteOperation($promiseAdapter, $config, $op);
4639

4740
if ($promiseAdapter instanceof SyncPromiseAdapter) {
4841
$result = $promiseAdapter->wait($result);
@@ -65,12 +58,7 @@ public function executeBatch(ServerConfig $config, array $operations)
6558
$result = [];
6659

6760
foreach ($operations as $operation) {
68-
$errors = $this->validateOperationParams($operation);
69-
if (!empty($errors)) {
70-
$result[] = $promiseAdapter->createFulfilled(new ExecutionResult(null, $errors));
71-
} else {
72-
$result[] = $this->promiseToExecuteOperation($promiseAdapter, $config, $operation);
73-
}
61+
$result[] = $this->promiseToExecuteOperation($promiseAdapter, $config, $operation);
7462
}
7563

7664
$result = $promiseAdapter->all($result);
@@ -91,6 +79,14 @@ public function executeBatch(ServerConfig $config, array $operations)
9179
private function promiseToExecuteOperation(PromiseAdapter $promiseAdapter, ServerConfig $config, OperationParams $op)
9280
{
9381
try {
82+
$errors = $this->validateOperationParams($op);
83+
84+
if (!empty($errors)) {
85+
return $promiseAdapter->createFulfilled(
86+
new ExecutionResult(null, $errors)
87+
);
88+
}
89+
9490
$doc = $op->queryId ? static::loadPersistedQuery($config, $op) : $op->query;
9591

9692
if (!$doc instanceof DocumentNode) {

0 commit comments

Comments
 (0)