Map.php in GraphQL 8.4
File
src/GraphQL/Resolver/Map.php
View source
<?php
namespace Drupal\graphql\GraphQL\Resolver;
use Drupal\graphql\GraphQL\Execution\FieldContext;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use GraphQL\Type\Definition\ResolveInfo;
class Map implements ResolverInterface {
protected $resolver;
public function __construct(ResolverInterface $resolver) {
$this->resolver = $resolver;
}
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);
}
}
Classes
Name |
Description |
Map |
Execute a resolver for each item in the given list. |