Skip to content

Commit 93f4929

Browse files
fregataaclaudelablup-octodog
authored
feat(BA-5738): add session_v2 single-node GraphQL query with RBAC (#11124)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: octodog <mu001@lablup.com>
1 parent 045aef4 commit 93f4929

6 files changed

Lines changed: 31 additions & 0 deletions

File tree

changes/11124.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `session_v2(id)` GraphQL single-node query with RBAC-enforced single-session reads across GraphQL, REST v2, SDK, and CLI.

docs/manager/graphql-reference/supergraph.graphql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13078,6 +13078,11 @@ type Query
1307813078
"""
1307913079
projectSessionsV2(scope: ProjectSessionV2Scope!, filter: SessionV2Filter = null, orderBy: [SessionV2OrderBy!] = null, before: String = null, after: String = null, first: Int = null, last: Int = null, limit: Int = null, offset: Int = null): SessionV2Connection! @join__field(graph: STRAWBERRY)
1308013080

13081+
"""
13082+
Added in UNRELEASED. Query a single session by ID. Returns an error if not found.
13083+
"""
13084+
sessionV2(id: UUID!): SessionV2 @join__field(graph: STRAWBERRY)
13085+
1308113086
"""Added in 25.19.0. List deployments within a specific project."""
1308213087
projectDeployments(scope: ProjectDeploymentScope!, filter: DeploymentFilter = null, orderBy: [DeploymentOrderBy!] = null, before: String = null, after: String = null, first: Int = null, last: Int = null, limit: Int = null, offset: Int = null): ModelDeploymentConnection @join__field(graph: STRAWBERRY)
1308313088

docs/manager/graphql-reference/v2-schema.graphql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8283,6 +8283,11 @@ type Query {
82838283
"""
82848284
projectSessionsV2(scope: ProjectSessionV2Scope!, filter: SessionV2Filter = null, orderBy: [SessionV2OrderBy!] = null, before: String = null, after: String = null, first: Int = null, last: Int = null, limit: Int = null, offset: Int = null): SessionV2Connection!
82858285

8286+
"""
8287+
Added in UNRELEASED. Query a single session by ID. Returns an error if not found.
8288+
"""
8289+
sessionV2(id: UUID!): SessionV2
8290+
82868291
"""Added in 25.19.0. List deployments within a specific project."""
82878292
projectDeployments(scope: ProjectDeploymentScope!, filter: DeploymentFilter = null, orderBy: [DeploymentOrderBy!] = null, before: String = null, after: String = null, first: Int = null, last: Int = null, limit: Int = null, offset: Int = null): ModelDeploymentConnection
82888293

src/ai/backend/manager/api/gql/schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@
382382
admin_sessions_v2,
383383
enqueue_session,
384384
project_sessions_v2,
385+
session_v2,
385386
terminate_project_sessions_v2,
386387
)
387388
from .storage_host import my_storage_host_permissions
@@ -499,6 +500,7 @@ class Query:
499500
admin_login_history_v2 = admin_login_history_v2
500501
admin_sessions_v2 = admin_sessions_v2
501502
project_sessions_v2 = project_sessions_v2
503+
session_v2 = session_v2
502504
project_deployments = project_deployments
503505
my_deployments = my_deployments
504506
resource_slot_type = resource_slot_type

src/ai/backend/manager/api/gql/session/resolver/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
admin_sessions_v2,
55
enqueue_session,
66
project_sessions_v2,
7+
session_v2,
78
terminate_project_sessions_v2,
89
)
910

1011
__all__ = [
1112
"admin_sessions_v2",
1213
"enqueue_session",
1314
"project_sessions_v2",
15+
"session_v2",
1416
"terminate_project_sessions_v2",
1517
]

src/ai/backend/manager/api/gql/session/resolver/session.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
AdminSearchSessionsInput,
1111
TerminateSessionsInProjectInput,
1212
)
13+
from ai.backend.common.meta.meta import NEXT_RELEASE_VERSION
14+
from ai.backend.common.types import SessionId
1315
from ai.backend.manager.api.gql.base import encode_cursor
1416
from ai.backend.manager.api.gql.decorators import (
1517
BackendAIGQLMeta,
@@ -32,6 +34,20 @@
3234
from ai.backend.manager.errors.user import UserNotFound
3335

3436

37+
@gql_root_field(
38+
BackendAIGQLMeta(
39+
added_version=NEXT_RELEASE_VERSION,
40+
description="Query a single session by ID. Returns an error if not found.",
41+
)
42+
) # type: ignore[misc]
43+
async def session_v2(
44+
info: Info[StrawberryGQLContext],
45+
id: UUID,
46+
) -> SessionV2GQL | None:
47+
payload = await info.context.adapters.session.get(SessionId(id))
48+
return SessionV2GQL.from_pydantic(payload)
49+
50+
3551
@gql_root_field(
3652
BackendAIGQLMeta(
3753
added_version="26.3.0",

0 commit comments

Comments
 (0)