Introspection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
c 0
b 0
f 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A introspect() 0 5 1
A __construct() 0 2 1
1
<?php
2
3
namespace Drupal\graphql\GraphQL\Utility;
4
5
use Drupal\graphql\GraphQL\Execution\QueryProcessor;
6
use GraphQL\Server\OperationParams;
7
use GraphQL\Type\Introspection as IntrospectionType;
8
9
class Introspection {
10
11
  /**
12
   * @var \Drupal\graphql\GraphQL\Execution\QueryProcessor
13
   */
14
  protected $queryProcessor;
15
16
  /**
17
   * Constructs an Introspection object.
18
   *
19
   * @param \Drupal\graphql\GraphQL\Execution\QueryProcessor $queryProcessor
20
   *   The query processor srevice.
21
   */
22
  public function __construct(QueryProcessor $queryProcessor) {
23
    $this->queryProcessor = $queryProcessor;
24
  }
25
26
  /**
27
   * Perform an introspection query and return result.
28
   *
29
   * @param string $schema
30
   *   The name of the graphql schema to introspect.
31
   *
32
   * @return array The introspection result as an array.
33
   *   The introspection result as an array.
34
   */
35
  public function introspect($schema) {
36
    $query = IntrospectionType::getIntrospectionQuery(['descriptions' => TRUE]);
37
    $operation = OperationParams::create(['query' => $query]);
38
    $result = $this->queryProcessor->processQuery($schema, $operation);
39
    return $result->toArray();
40
  }
41
42
}
43