Issues (645)

src/Controller/VoyagerController.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Drupal\graphql\Controller;
4
5
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
0 ignored issues
show
The type Drupal\Core\DependencyIn...ainerInjectionInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Drupal\graphql\GraphQL\Utility\Introspection;
7
use Symfony\Component\DependencyInjection\ContainerInterface;
0 ignored issues
show
The type Symfony\Component\Depend...tion\ContainerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Controller for the GraphQL Voyager visualisation API.
11
 */
12
class VoyagerController implements ContainerInjectionInterface {
13
  /**
14
   * The introspection service.
15
   *
16
   * @var \Drupal\graphql\GraphQL\Utility\Introspection
17
   */
18
  protected $introspection;
19
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public static function create(ContainerInterface $container) {
24
    return new static($container->get('graphql.introspection'));
25
  }
26
27
  /**
28
   * VoyagerController constructor.
29
   *
30
   * @param \Drupal\graphql\GraphQL\Utility\Introspection $introspection
31
   *   The GraphQL introspection service.
32
   */
33
  public function __construct(Introspection $introspection) {
34
    $this->introspection = $introspection;
35
  }
36
37
  /**
38
   * Display for the GraphQL Voyager visualization API.
39
   *
40
   * @param string $schema
41
   *   The name of the schema to use.
42
   *
43
   * @return array The render array.
44
   *   The render array.
45
   */
46
  public function viewVoyager($schema) {
47
    $introspectionData = $this->introspection->introspect($schema);
48
49
    return [
50
      '#type' => 'page',
51
      '#theme' => 'page__graphql_voyager',
52
      '#attached' => [
53
        'library' => ['graphql/voyager'],
54
        'drupalSettings' => [
55
          'graphqlIntrospectionData' => $introspectionData,
56
        ],
57
      ],
58
    ];
59
  }
60
61
}
62