You are here

public function SchemaOverviewController::listSchemas in GraphQL 8.3

Renders a table of available schemas.

Return value

array The renderable array for the overview table.

1 string reference to 'SchemaOverviewController::listSchemas'
graphql.routing.yml in ./graphql.routing.yml
graphql.routing.yml

File

src/Controller/SchemaOverviewController.php, line 58

Class

SchemaOverviewController

Namespace

Drupal\graphql\Controller

Code

public function listSchemas() {
  $table = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Schema'),
      $this
        ->t('Provider'),
      $this
        ->t('Operations'),
    ],
    '#attributes' => [
      'id' => 'graphql-schemas',
    ],
  ];
  foreach ($this->schemaManager
    ->getDefinitions() as $key => $definition) {
    $table["schema:{$key}"]['name'] = [
      '#plain_text' => $definition['name'],
    ];
    $table["schema:{$key}"]['provider'] = [
      '#plain_text' => $this->moduleHandler
        ->getName($definition['provider']),
    ];
    $table["schema:{$key}"]['operations'] = $this
      ->buildOperations($key, $definition);
  }
  return $table;
}