ViewResultList::resolveValues()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 4
1
<?php
2
3
namespace Drupal\graphql_views\Plugin\GraphQL\Fields;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
/**
10
 * Expose results of a view.
11
 *
12
 * @GraphQLField(
13
 *   id = "view_result",
14
 *   name = "results",
15
 *   secure = true,
16
 *   provider = "views",
17
 *   deriver = "Drupal\graphql_views\Plugin\Deriver\Fields\ViewResultListDeriver"
18
 * )
19
 */
20
class ViewResultList extends FieldPluginBase {
21
22
  /**
23
   * {@inheritdoc}
24
   */
25
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
26
    if (isset($value['rows'])) {
27
      foreach ($value['rows'] as $row) {
28
        yield $row;
29
      }
30
    }
31
  }
32
33
}
34