You are here

class VoyagerAccessCheck in GraphQL 8.4

Grants access to the GraphQL voyager for admins.

Hierarchy

Expanded class hierarchy of VoyagerAccessCheck

1 string reference to 'VoyagerAccessCheck'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses VoyagerAccessCheck
access_check.graphql.voyager in ./graphql.services.yml
Drupal\graphql\Access\VoyagerAccessCheck

File

src/Access/VoyagerAccessCheck.php, line 13

Namespace

Drupal\graphql\Access
View source
class VoyagerAccessCheck implements AccessInterface {

  /**
   * Checks access.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   * @param \Drupal\graphql\Entity\ServerInterface $graphql_server
   *   The server instance.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  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",
    ]);
  }

}

Members