You are here

public function VoyagerAccessCheck::access in GraphQL 8.4

Checks access.

Parameters

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

\Drupal\graphql\Entity\ServerInterface $graphql_server: The server instance.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

src/Access/VoyagerAccessCheck.php, line 26

Class

VoyagerAccessCheck
Grants access to the GraphQL voyager for admins.

Namespace

Drupal\graphql\Access

Code

public function access(AccountInterface $account, ServerInterface $graphql_server) {
  if ($account
    ->hasPermission('bypass graphql access')) {
    return AccessResult::allowed();
  }
  $id = $graphql_server
    ->id();
  return AccessResult::allowedIfHasPermissions($account, [
    "use {$id} graphql voyager",
    "execute {$id} arbitrary graphql requests",
  ]);
}