public function ExplorerController::viewExplorer in GraphQL 8.3
Same name and namespace in other branches
- 8.4 src/Controller/ExplorerController.php \Drupal\graphql\Controller\ExplorerController::viewExplorer()
- 8 src/Controller/ExplorerController.php \Drupal\graphql\Controller\ExplorerController::viewExplorer()
- 8.2 src/Controller/ExplorerController.php \Drupal\graphql\Controller\ExplorerController::viewExplorer()
Controller for the GraphiQL query builder IDE.
Parameters
string $schema: The name of the schema.
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
array The render array. The render array.
File
- src/Controller/ ExplorerController.php, line 79 
Class
- ExplorerController
- Controller for the GraphiQL query builder IDE.
Namespace
Drupal\graphql\ControllerCode
public function viewExplorer($schema, Request $request) {
  $url = $this->urlGenerator
    ->generate("graphql.query.{$schema}");
  $introspectionData = $this->introspection
    ->introspect($schema);
  return [
    '#type' => 'page',
    '#theme' => 'page__graphql_explorer',
    '#attached' => [
      'library' => [
        'graphql/explorer',
      ],
      'drupalSettings' => [
        'graphqlRequestUrl' => $url,
        'graphqlIntrospectionData' => $introspectionData,
        'graphqlQuery' => $request
          ->get('query'),
        'graphqlVariables' => $request
          ->get('variables'),
      ],
    ],
  ];
}