mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 13:29:56 +02:00
[MOBIL-319] chore: combine user details and current workspace details in a single query (#1406)
* chore: added user information query in dashboard * dev: removed print statements
This commit is contained in:
36
apiserver/plane/graphql/queries/dashboard.py
Normal file
36
apiserver/plane/graphql/queries/dashboard.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import Optional
|
||||
|
||||
# Third-Party Imports
|
||||
import strawberry
|
||||
from asgiref.sync import sync_to_async
|
||||
|
||||
# Strawberry Imports
|
||||
from strawberry.types import Info
|
||||
from strawberry.permission import PermissionExtension
|
||||
|
||||
|
||||
# Module Imports
|
||||
from plane.db.models import Workspace, Profile
|
||||
from plane.graphql.types.dashboard import UserInformationType
|
||||
from plane.graphql.permissions.workspace import IsAuthenticated
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class userInformationQuery:
|
||||
@strawberry.field(
|
||||
extensions=[PermissionExtension(permissions=[IsAuthenticated()])]
|
||||
)
|
||||
async def userInformation(self, info: Info) -> UserInformationType:
|
||||
profile = await sync_to_async(Profile.objects.get)(
|
||||
user=info.context.user
|
||||
)
|
||||
|
||||
workspace_id = (
|
||||
profile.last_workspace_id if profile.last_workspace_id else None
|
||||
)
|
||||
if workspace_id:
|
||||
workspace = await sync_to_async(Workspace.objects.get)(
|
||||
id=workspace_id
|
||||
)
|
||||
|
||||
return UserInformationType(user=info.context.user, workspace=workspace)
|
||||
@@ -46,6 +46,7 @@ from .queries.issues import (
|
||||
IssuesSearchQuery,
|
||||
SubIssuesQuery,
|
||||
)
|
||||
from .queries.dashboard import userInformationQuery
|
||||
|
||||
# mutations
|
||||
from .mutations.workspace import WorkspaceMutation, WorkspaceInviteMutation
|
||||
@@ -125,6 +126,7 @@ class Query(
|
||||
ModuleIssueUserPropertyQuery,
|
||||
IssueRelationQuery,
|
||||
IssuesSearchQuery,
|
||||
userInformationQuery,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
12
apiserver/plane/graphql/types/dashboard.py
Normal file
12
apiserver/plane/graphql/types/dashboard.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# strawberry imports
|
||||
import strawberry
|
||||
|
||||
# module imports
|
||||
from plane.graphql.types.users import UserType
|
||||
from plane.graphql.types.workspace import WorkspaceType
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class UserInformationType:
|
||||
user: UserType
|
||||
workspace: WorkspaceType
|
||||
Reference in New Issue
Block a user