You are here

public function Map::resolve in GraphQL 8.4

Resolve values for the fields.

Parameters

mixed $value:

mixed $args:

\Drupal\graphql\GraphQL\Execution\ResolveContext $context:

\GraphQL\Type\Definition\ResolveInfo $info:

\Drupal\graphql\GraphQL\Execution\FieldContext $field:

Return value

mixed

Overrides ResolverInterface::resolve

File

src/GraphQL/Resolver/Map.php, line 33

Class

Map
Execute a resolver for each item in the given list.

Namespace

Drupal\graphql\GraphQL\Resolver

Code

public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {
  if (!is_iterable($value)) {
    return NULL;
  }
  $array = is_array($value) ? $value : iterator_to_array($value);
  return array_map(function ($item) use ($args, $context, $info, $field) {
    return $this->resolver
      ->resolve($item, $args, $context, $info, $field);
  }, $array);
}