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