-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathExecutor.php
More file actions
60 lines (54 loc) · 1.68 KB
/
Executor.php
File metadata and controls
60 lines (54 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Overblog\GraphQLBundle\Executor;
use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Promise\Promise;
use GraphQL\Executor\Promise\PromiseAdapter;
use GraphQL\GraphQL;
use GraphQL\Type\Schema;
use Overblog\GraphQLBundle\Executor\Promise\PromiseAdapterInterface;
use RuntimeException;
use function func_get_args;
use function method_exists;
use function sprintf;
final class Executor implements ExecutorInterface
{
/**
* {@inheritdoc}
*/
public function execute(
PromiseAdapter $promiseAdapter,
Schema $schema,
string $requestString,
$rootValue = null,
$contextValue = null,
$variableValues = null,
$operationName = null,
?callable $fieldResolver = null,
?array $validationRules = null
): ExecutionResult {
if (!method_exists($promiseAdapter, 'wait')) {
throw new RuntimeException(
sprintf(
'PromiseAdapter should be an object instantiating "%s" or "%s" with a "wait" method.',
PromiseAdapterInterface::class,
PromiseAdapter::class
)
);
}
return $promiseAdapter->wait(GraphQL::promiseToExecute(...func_get_args()));
}
public function executeAsync(
PromiseAdapter $promiseAdapter,
Schema $schema,
string $requestString,
$rootValue = null,
$contextValue = null,
$variableValues = null,
$operationName = null,
?callable $fieldResolver = null,
?array $validationRules = null
): Promise {
return GraphQL::promiseToExecute(...func_get_args());
}
}