mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 06:16:05 +03:00
Minor Executor tweaks
This commit is contained in:
parent
085516bdda
commit
d5e3d08d85
@ -85,7 +85,6 @@ class Executor
|
|||||||
* @param array|\ArrayAccess $variableValues
|
* @param array|\ArrayAccess $variableValues
|
||||||
* @param null $operationName
|
* @param null $operationName
|
||||||
* @param callable $fieldResolver
|
* @param callable $fieldResolver
|
||||||
* @param PromiseAdapter $promiseAdapter
|
|
||||||
*
|
*
|
||||||
* @return ExecutionResult|Promise
|
* @return ExecutionResult|Promise
|
||||||
*/
|
*/
|
||||||
@ -96,22 +95,14 @@ class Executor
|
|||||||
$contextValue = null,
|
$contextValue = null,
|
||||||
$variableValues = null,
|
$variableValues = null,
|
||||||
$operationName = null,
|
$operationName = null,
|
||||||
callable $fieldResolver = null,
|
callable $fieldResolver = null
|
||||||
PromiseAdapter $promiseAdapter = null
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$promiseAdapter = $promiseAdapter ?: self::getPromiseAdapter();
|
// TODO: deprecate (just always use SyncAdapter here) and have `promiseToExecute()` for other cases
|
||||||
|
$promiseAdapter = self::getPromiseAdapter();
|
||||||
|
|
||||||
$result = self::promiseToExecute(
|
$result = self::promiseToExecute($promiseAdapter, $schema, $ast, $rootValue, $contextValue,
|
||||||
$promiseAdapter,
|
$variableValues, $operationName, $fieldResolver);
|
||||||
$schema,
|
|
||||||
$ast,
|
|
||||||
$rootValue,
|
|
||||||
$contextValue,
|
|
||||||
$variableValues,
|
|
||||||
$operationName,
|
|
||||||
$fieldResolver
|
|
||||||
);
|
|
||||||
|
|
||||||
// Wait for promised results when using sync promises
|
// Wait for promised results when using sync promises
|
||||||
if ($promiseAdapter instanceof SyncPromiseAdapter) {
|
if ($promiseAdapter instanceof SyncPromiseAdapter) {
|
||||||
@ -122,7 +113,7 @@ class Executor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as executeQuery(), but requires promise adapter and returns a promise which is always
|
* Same as execute(), but requires promise adapter and returns a promise which is always
|
||||||
* fulfilled with an instance of ExecutionResult and never rejected.
|
* fulfilled with an instance of ExecutionResult and never rejected.
|
||||||
*
|
*
|
||||||
* Useful for async PHP platforms.
|
* Useful for async PHP platforms.
|
||||||
@ -150,22 +141,14 @@ class Executor
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$exeContext = self::buildExecutionContext(
|
$exeContext = self::buildExecutionContext($schema, $ast, $rootValue, $contextValue, $variableValues,
|
||||||
$schema,
|
$operationName, $fieldResolver, $promiseAdapter);
|
||||||
$ast,
|
|
||||||
$rootValue,
|
|
||||||
$contextValue,
|
|
||||||
$variableValues,
|
|
||||||
$operationName,
|
|
||||||
$fieldResolver,
|
|
||||||
$promiseAdapter
|
|
||||||
);
|
|
||||||
} catch (Error $e) {
|
} catch (Error $e) {
|
||||||
return $promiseAdapter->createFulfilled(new ExecutionResult(null, [$e]));
|
return $promiseAdapter->createFulfilled(new ExecutionResult(null, [$e]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$executor = new self($exeContext);
|
$executor = new self($exeContext);
|
||||||
return $executor->executeQuery();
|
return $executor->doExecute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,7 +274,7 @@ class Executor
|
|||||||
/**
|
/**
|
||||||
* @return Promise
|
* @return Promise
|
||||||
*/
|
*/
|
||||||
private function executeQuery()
|
private function doExecute()
|
||||||
{
|
{
|
||||||
// Return a Promise that will eventually resolve to the data described by
|
// Return a Promise that will eventually resolve to the data described by
|
||||||
// The "Response" section of the GraphQL specification.
|
// The "Response" section of the GraphQL specification.
|
||||||
|
Loading…
Reference in New Issue
Block a user