1 | <?php |
||
2 | |||
3 | namespace Drupal\graphql\Controller; |
||
4 | |||
5 | use Drupal\Core\DependencyInjection\ContainerInjectionInterface; |
||
0 ignored issues
–
show
|
|||
6 | use Drupal\Core\Routing\UrlGeneratorInterface; |
||
0 ignored issues
–
show
The type
Drupal\Core\Routing\UrlGeneratorInterface 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | use Drupal\Core\StringTranslation\StringTranslationTrait; |
||
0 ignored issues
–
show
The type
Drupal\Core\StringTransl...\StringTranslationTrait 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
8 | use Drupal\graphql\GraphQL\Schema\SchemaLoader; |
||
0 ignored issues
–
show
The type
Drupal\graphql\GraphQL\Schema\SchemaLoader 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
9 | use Drupal\graphql\GraphQL\Utility\Introspection; |
||
10 | use Drupal\graphql\Plugin\SchemaPluginManager; |
||
11 | 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
12 | use Symfony\Component\HttpFoundation\Request; |
||
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\Request 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
13 | |||
14 | /** |
||
15 | * Controller for the GraphiQL query builder IDE. |
||
16 | */ |
||
17 | class ExplorerController implements ContainerInjectionInterface { |
||
18 | use StringTranslationTrait; |
||
19 | |||
20 | /** |
||
21 | * The URL generator service. |
||
22 | * |
||
23 | * @var \Drupal\Core\Routing\UrlGeneratorInterface |
||
24 | */ |
||
25 | protected $urlGenerator; |
||
26 | |||
27 | /** |
||
28 | * The introspection service. |
||
29 | * |
||
30 | * @var \Drupal\graphql\GraphQL\Utility\Introspection |
||
31 | */ |
||
32 | protected $introspection; |
||
33 | |||
34 | /** |
||
35 | * The schema plugin manager. |
||
36 | * |
||
37 | * @var \Drupal\graphql\Plugin\SchemaPluginManager |
||
38 | */ |
||
39 | protected $pluginManager; |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | public static function create(ContainerInterface $container) { |
||
45 | return new static( |
||
46 | $container->get('url_generator'), |
||
47 | $container->get('graphql.introspection'), |
||
48 | $container->get('plugin.manager.graphql.schema') |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * ExplorerController constructor. |
||
54 | * |
||
55 | * @param \Drupal\Core\Routing\UrlGeneratorInterface $urlGenerator |
||
56 | * The url generator service. |
||
57 | * @param \Drupal\graphql\GraphQL\Utility\Introspection $introspection |
||
58 | * The introspection service. |
||
59 | * @param \Drupal\graphql\Plugin\SchemaPluginManager $pluginManager |
||
60 | * The schema plugin manager. |
||
61 | */ |
||
62 | public function __construct(UrlGeneratorInterface $urlGenerator, Introspection $introspection, SchemaPluginManager $pluginManager) { |
||
63 | $this->urlGenerator = $urlGenerator; |
||
64 | $this->introspection = $introspection; |
||
65 | $this->pluginManager = $pluginManager; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Controller for the GraphiQL query builder IDE. |
||
70 | * |
||
71 | * @param string $schema |
||
72 | * The name of the schema. |
||
73 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
74 | * The request. |
||
75 | * |
||
76 | * @return array The render array. |
||
77 | * The render array. |
||
78 | */ |
||
79 | public function viewExplorer($schema, Request $request) { |
||
80 | $url = $this->urlGenerator->generate("graphql.query.$schema"); |
||
81 | $introspectionData = $this->introspection->introspect($schema); |
||
82 | |||
83 | return [ |
||
84 | '#type' => 'page', |
||
85 | '#theme' => 'page__graphql_explorer', |
||
86 | '#attached' => [ |
||
87 | 'library' => ['graphql/explorer'], |
||
88 | 'drupalSettings' => [ |
||
89 | 'graphqlRequestUrl' => $url, |
||
90 | 'graphqlIntrospectionData' => $introspectionData, |
||
91 | 'graphqlQuery' => $request->get('query'), |
||
92 | 'graphqlVariables' => $request->get('variables'), |
||
93 | ], |
||
94 | ], |
||
95 | ]; |
||
96 | } |
||
97 | } |
||
98 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths