class Map in GraphQL 8.4
Execute a resolver for each item in the given list.
Hierarchy
- class \Drupal\graphql\GraphQL\Resolver\Map implements ResolverInterface
Expanded class hierarchy of Map
1 file declares its use of Map
- ResolverBuilder.php in src/
GraphQL/ ResolverBuilder.php
File
- src/
GraphQL/ Resolver/ Map.php, line 12
Namespace
Drupal\graphql\GraphQL\ResolverView source
class Map implements ResolverInterface {
/**
* Resolver to tap.
*
* @var mixed
*/
protected $resolver;
/**
* Map constructor.
*
* @param \Drupal\graphql\GraphQL\Resolver\ResolverInterface $resolver
*/
public function __construct(ResolverInterface $resolver) {
$this->resolver = $resolver;
}
/**
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Map:: |
protected | property | Resolver to tap. | |
Map:: |
public | function |
Resolve values for the fields. Overrides ResolverInterface:: |
|
Map:: |
public | function | Map constructor. |