You are here

public static function DeferredUtility::returnFinally in GraphQL 8.4

Execute a callback after a value is resolved and return the result.

Parameters

mixed $value:

callable $callback:

Return value

\GraphQL\Executor\Promise\Adapter\SyncPromise|mixed

5 calls to DeferredUtility::returnFinally()
Composite::resolve in src/GraphQL/Resolver/Composite.php
Resolve values for the fields.
Condition::resolve in src/GraphQL/Resolver/Condition.php
Resolve values for the fields.
DataProducerProxy::prepare in src/Plugin/GraphQL/DataProducer/DataProducerProxy.php
Instantiate the actual data producer and populate it with context values.
DataProducerProxy::resolve in src/Plugin/GraphQL/DataProducer/DataProducerProxy.php
Resolve field value.
DefaultValue::resolve in src/GraphQL/Resolver/DefaultValue.php
Resolve values for the fields.

File

src/GraphQL/Utility/DeferredUtility.php, line 65

Class

DeferredUtility
Helper class for dealing with deferred promises.

Namespace

Drupal\graphql\GraphQL\Utility

Code

public static function returnFinally($value, callable $callback) {
  if ($value instanceof SyncPromise) {
    return $value
      ->then(function ($value) use ($callback) {
      return $callback($value);
    });
  }
  return $callback($value);
}