You are here

public function CurrentUser::resolve in GraphQL 8.4

Returns current user.

Parameters

\Drupal\graphql\GraphQL\Execution\FieldContext $field_context: Field context.

Return value

\Drupal\Core\Session\AccountInterface The current user.

File

src/Plugin/GraphQL/DataProducer/User/CurrentUser.php, line 70

Class

CurrentUser
Gets the current user.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer\User

Code

public function resolve(FieldContext $field_context) : AccountInterface {

  // Response must be cached based on current user as a cache context,
  // otherwise a new user would became a previous user.
  $field_context
    ->addCacheableDependency($this->currentUser);
  return $this->currentUser;
}