diff --git a/README.md b/README.md index a1cc75e..817f8c6 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ resolveType | `callback($value, $context, ResolveInfo $info) => objectType` | An **Notes**: -1. If `resolveType` option is omitted, GraphQL PHP will loop through all interface implementors and use their `isTypeOf()` method to pick the first suitable one. This is obviously less efficient than single `resolveType` call. So it is recommended to define `resolveType` when possible. +1. If `resolveType` option is omitted, GraphQL PHP will loop through all interface implementers and use their `isTypeOf()` method to pick the first suitable one. This is obviously less efficient than single `resolveType` call. So it is recommended to define `resolveType` when possible. 2. Interface types do not participate in data fetching. They just resolve actual `object` type which will be asked for data when GraphQL query is executed. diff --git a/src/Executor/Promise/Adapter/SyncPromiseAdapter.php b/src/Executor/Promise/Adapter/SyncPromiseAdapter.php index 38be0df..e0791bc 100644 --- a/src/Executor/Promise/Adapter/SyncPromiseAdapter.php +++ b/src/Executor/Promise/Adapter/SyncPromiseAdapter.php @@ -128,6 +128,7 @@ class SyncPromiseAdapter implements PromiseAdapter */ public function wait(Promise $promise) { + $this->beforeWait($promise); $dfdQueue = Deferred::getQueue(); $promiseQueue = SyncPromise::getQueue(); @@ -137,6 +138,7 @@ class SyncPromiseAdapter implements PromiseAdapter ) { Deferred::runQueue(); SyncPromise::runQueue(); + $this->onWait($promise); } /** @var SyncPromise $syncPromise */ @@ -150,4 +152,22 @@ class SyncPromiseAdapter implements PromiseAdapter throw new InvariantViolation("Could not resolve promise"); } + + /** + * Execute just before starting to run promise completion + * + * @param Promise $promise + */ + protected function beforeWait(Promise $promise) + { + } + + /** + * Execute while running promise completion + * + * @param Promise $promise + */ + protected function onWait(Promise $promise) + { + } }