Skip to content

Commit

Permalink
feat(BA-595): Add row_id field to UserNode GQL schema
Browse files Browse the repository at this point in the history
  • Loading branch information
agatha197 committed Jan 22, 2025
1 parent 5b79ec5 commit 55c8158
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/3525.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a `row_id` field to the `UserNode` GraphQL schema to enable querying and mutating users by ID.
6 changes: 4 additions & 2 deletions src/ai/backend/manager/models/gql_models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class UserNode(graphene.ObjectType):
class Meta:
interfaces = (AsyncNode,)

row_id = graphene.UUID(description="Added in 25.1.0. The undecoded id value stored in DB.")
username = graphene.String(description="Unique username of the user.")
email = graphene.String(description="Unique email of the user.")
need_password_change = graphene.Boolean()
Expand Down Expand Up @@ -57,6 +58,7 @@ class Meta:
def from_row(cls, ctx: GraphQueryContext, row: UserRow) -> Self:
return cls(
id=row.uuid,
row_id=row.uuid,
username=row.username,
email=row.email,
need_password_change=row.need_password_change,
Expand Down Expand Up @@ -87,7 +89,7 @@ async def get_node(cls, info: graphene.ResolveInfo, id) -> Self:
return cls.from_row(graph_ctx, user_row)

_queryfilter_fieldspec: Mapping[str, FieldSpecItem] = {
"uuid": ("uuid", None),
"row_id": ("id", None),
"username": ("username", None),
"email": ("email", None),
"need_password_change": ("need_password_change", None),
Expand All @@ -109,7 +111,7 @@ async def get_node(cls, info: graphene.ResolveInfo, id) -> Self:
}

_queryorder_colmap: Mapping[str, OrderSpecItem] = {
"uuid": ("uuid", None),
"row_id": ("id", None),
"username": ("username", None),
"email": ("email", None),
"need_password_change": ("need_password_change", None),
Expand Down

0 comments on commit 55c8158

Please sign in to comment.