"""Authentication queries for GraphQL."""

import strawberry
from strawberry.types import Info

from ..types import UserType


@strawberry.type
class AuthQueries:
    """Authentication queries."""

    @strawberry.field
    def me(self, info: Info) -> UserType | None:
        """Get the currently authenticated user."""
        user = info.context.user

        if not user or not user.is_authenticated:
            return None

        return UserType.from_model(user)
