SyncPromiseAdapter
in package
implements
PromiseAdapter
Allows changing order of field resolution even in sync environments (by leveraging queue of deferreds and promises)
Interfaces, Classes, Traits and Enums
- PromiseAdapter
- Provides a means for integration of async PHP platforms ([related docs](data-fetching.md#async-php))
Table of Contents
- all() : Promise
- Given an array of promises (or values), returns a promise that is fulfilled when all the items in the array are fulfilled.
- convertThenable() : Promise
- Converts thenable of the underlying platform into GraphQL\Executor\Promise\Promise instance
- create() : Promise
- Creates a Promise
- createFulfilled() : Promise
- Creates a fulfilled Promise for a value if the value is not a promise.
- createRejected() : Promise
- Creates a rejected promise for a reason if the reason is not a promise. If the provided reason is a promise, then it is returned as-is.
- isThenable() : bool
- Return true if the value is a promise or a deferred of the underlying platform
- then() : Promise
- Accepts our Promise wrapper, extracts adopted promise out of it and executes actual `then` logic described in Promises/A+ specs. Then returns new wrapped instance of GraphQL\Executor\Promise\Promise.
- wait() : ExecutionResult
- Synchronously wait when promise completes
- beforeWait() : mixed
- Execute just before starting to run promise completion
- onWait() : mixed
- Execute while running promise completion
Methods
all()
Given an array of promises (or values), returns a promise that is fulfilled when all the items in the array are fulfilled.
public
all(array<string|int, mixed> $promisesOrValues) : Promise
Parameters
- $promisesOrValues : array<string|int, mixed>
-
Promises or values.
Tags
Return values
Promise —convertThenable()
Converts thenable of the underlying platform into GraphQL\Executor\Promise\Promise instance
public
convertThenable(mixed $thenable) : Promise
Parameters
- $thenable : mixed
Tags
Return values
Promise —create()
Creates a Promise
public
create(callable $resolver) : Promise
Parameters
- $resolver : callable
Tags
Return values
Promise —createFulfilled()
Creates a fulfilled Promise for a value if the value is not a promise.
public
createFulfilled([mixed $value = null ]) : Promise
Parameters
- $value : mixed = null
Tags
Return values
Promise —createRejected()
Creates a rejected promise for a reason if the reason is not a promise. If the provided reason is a promise, then it is returned as-is.
public
createRejected(mixed $reason) : Promise
Parameters
- $reason : mixed
Tags
Return values
Promise —isThenable()
Return true if the value is a promise or a deferred of the underlying platform
public
isThenable(mixed $value) : bool
Parameters
- $value : mixed
Tags
Return values
bool —then()
Accepts our Promise wrapper, extracts adopted promise out of it and executes actual `then` logic described in Promises/A+ specs. Then returns new wrapped instance of GraphQL\Executor\Promise\Promise.
public
then(Promise $promise[, callable|null $onFulfilled = null ][, callable|null $onRejected = null ]) : Promise
Parameters
- $promise : Promise
- $onFulfilled : callable|null = null
- $onRejected : callable|null = null
Tags
Return values
Promise —wait()
Synchronously wait when promise completes
public
wait(Promise $promise) : ExecutionResult
Parameters
- $promise : Promise
Return values
ExecutionResult —beforeWait()
Execute just before starting to run promise completion
protected
beforeWait(Promise $promise) : mixed
Parameters
- $promise : Promise
Return values
mixed —onWait()
Execute while running promise completion
protected
onWait(Promise $promise) : mixed
Parameters
- $promise : Promise