diff --git a/apiserver/plane/graphql/types/workspace.py b/apiserver/plane/graphql/types/workspace.py index b1518b3eac..0f8bb02719 100644 --- a/apiserver/plane/graphql/types/workspace.py +++ b/apiserver/plane/graphql/types/workspace.py @@ -1,10 +1,15 @@ # Third party imports from typing import Optional +# Third-party library imports +from asgiref.sync import sync_to_async + + # Strawberry imports import strawberry import strawberry_django from strawberry import auto +from strawberry.types import Info # Module Imports from plane.db.models import Workspace, WorkspaceMember @@ -25,6 +30,17 @@ class WorkspaceType: def owner(self) -> int: return self.owner_id + @strawberry_django.field + async def role(self, info: Info) -> Optional[int]: + workspace_member = await sync_to_async( + WorkspaceMember.objects.filter( + workspace=self.id, member=info.context.user.id + ).first + )() + if workspace_member: + return str(workspace_member.role) + return None + @strawberry_django.type(WorkspaceMember) class WorkspaceMemberType: