Issues (645)

src/Routing/QueryRoutes.php (4 issues)

1
<?php
2
3
namespace Drupal\graphql\Routing;
4
5
use Drupal\Core\Authentication\AuthenticationCollectorInterface;
0 ignored issues
show
The type Drupal\Core\Authenticati...ationCollectorInterface 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\Core\Routing\RouteSubscriberBase;
0 ignored issues
show
The type Drupal\Core\Routing\RouteSubscriberBase 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...
7
use Drupal\graphql\Plugin\SchemaPluginManager;
8
use Symfony\Component\Routing\Route;
0 ignored issues
show
The type Symfony\Component\Routing\Route 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...
9
use Symfony\Component\Routing\RouteCollection;
0 ignored issues
show
The type Symfony\Component\Routing\RouteCollection 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...
10
11
/**
12
 * Registers graphql query routes for all schemas.
13
 */
14
class QueryRoutes extends RouteSubscriberBase {
15
16
  /**
17
   * The graphql schema plugin manager.
18
   *
19
   * @var \Drupal\graphql\Plugin\SchemaPluginManager
20
   */
21
  protected $schemaManager;
22
23
  /**
24
   * The authentication collector.
25
   *
26
   * @var \Drupal\Core\Authentication\AuthenticationCollectorInterface
27
   */
28
  protected $authenticationCollector;
29
30
  /**
31
   * QueryRoutes constructor.
32
   *
33
   * @param \Drupal\graphql\Plugin\SchemaPluginManager $schemaManager
34
   *   The graphql schema plugin manager.
35
   * @param \Drupal\Core\Authentication\AuthenticationCollectorInterface $authenticationCollector
36
   *   The authentication collector.
37
   */
38
  public function __construct(SchemaPluginManager $schemaManager, AuthenticationCollectorInterface $authenticationCollector) {
39
    $this->schemaManager = $schemaManager;
40
    $this->authenticationCollector = $authenticationCollector;
41
  }
42
43
  /**
44
   * Alters existing routes for a specific collection.
45
   *
46
   * @param \Symfony\Component\Routing\RouteCollection $collection
47
   *   The route collection for adding routes.
48
   */
49
  protected function alterRoutes(RouteCollection $collection) {
50
    $routes = new RouteCollection();
51
    $providers = $this->authenticationCollector->getSortedProviders();
52
    $providerIds = array_keys($providers);
53
54
    foreach ($this->schemaManager->getDefinitions() as $key => $definition) {
55
      $routes->add("graphql.query.$key", new Route($definition['path'], [
56
        'schema' => $key,
57
        '_graphql' => TRUE,
58
        '_controller' => '\Drupal\graphql\Controller\RequestController::handleRequest',
59
        '_disable_route_normalizer' => 'TRUE',
60
      ], [
61
        '_graphql_query_access' => 'TRUE',
62
      ], [
63
        '_auth' => $providerIds,
64
      ]));
65
    }
66
67
    $collection->addCollection($routes);
68
  }
69
70
}
71