Skip to content

Commit d5e3d08

Browse files
committed
Minor Executor tweaks
1 parent 085516b commit d5e3d08

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

src/Executor/Executor.php

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public static function setDefaultFieldResolver(callable $fn)
8585
* @param array|\ArrayAccess $variableValues
8686
* @param null $operationName
8787
* @param callable $fieldResolver
88-
* @param PromiseAdapter $promiseAdapter
8988
*
9089
* @return ExecutionResult|Promise
9190
*/
@@ -96,22 +95,14 @@ public static function execute(
9695
$contextValue = null,
9796
$variableValues = null,
9897
$operationName = null,
99-
callable $fieldResolver = null,
100-
PromiseAdapter $promiseAdapter = null
98+
callable $fieldResolver = null
10199
)
102100
{
103-
$promiseAdapter = $promiseAdapter ?: self::getPromiseAdapter();
101+
// TODO: deprecate (just always use SyncAdapter here) and have `promiseToExecute()` for other cases
102+
$promiseAdapter = self::getPromiseAdapter();
104103

105-
$result = self::promiseToExecute(
106-
$promiseAdapter,
107-
$schema,
108-
$ast,
109-
$rootValue,
110-
$contextValue,
111-
$variableValues,
112-
$operationName,
113-
$fieldResolver
114-
);
104+
$result = self::promiseToExecute($promiseAdapter, $schema, $ast, $rootValue, $contextValue,
105+
$variableValues, $operationName, $fieldResolver);
115106

116107
// Wait for promised results when using sync promises
117108
if ($promiseAdapter instanceof SyncPromiseAdapter) {
@@ -122,7 +113,7 @@ public static function execute(
122113
}
123114

124115
/**
125-
* Same as executeQuery(), but requires promise adapter and returns a promise which is always
116+
* Same as execute(), but requires promise adapter and returns a promise which is always
126117
* fulfilled with an instance of ExecutionResult and never rejected.
127118
*
128119
* Useful for async PHP platforms.
@@ -150,22 +141,14 @@ public static function promiseToExecute(
150141
)
151142
{
152143
try {
153-
$exeContext = self::buildExecutionContext(
154-
$schema,
155-
$ast,
156-
$rootValue,
157-
$contextValue,
158-
$variableValues,
159-
$operationName,
160-
$fieldResolver,
161-
$promiseAdapter
162-
);
144+
$exeContext = self::buildExecutionContext($schema, $ast, $rootValue, $contextValue, $variableValues,
145+
$operationName, $fieldResolver, $promiseAdapter);
163146
} catch (Error $e) {
164147
return $promiseAdapter->createFulfilled(new ExecutionResult(null, [$e]));
165148
}
166149

167150
$executor = new self($exeContext);
168-
return $executor->executeQuery();
151+
return $executor->doExecute();
169152
}
170153

171154
/**
@@ -291,7 +274,7 @@ private function __construct(ExecutionContext $context)
291274
/**
292275
* @return Promise
293276
*/
294-
private function executeQuery()
277+
private function doExecute()
295278
{
296279
// Return a Promise that will eventually resolve to the data described by
297280
// The "Response" section of the GraphQL specification.

0 commit comments

Comments
 (0)