Background
ModelCardGQL.vfolder exposes the linked VFolder from a model card (api/gql/model_card/types.py:221-235), but the reverse direction is not exposed. There is no way to obtain the matching model card from a vfolder via either REST v2 or GraphQL.
Findings:
-
VFolderGQL (api/gql/vfolder_v2/types/node.py) has no model_card field.
-
VFolderNode REST v2 DTO (common/dto/manager/v2/vfolder/response.py:57) has no model_card field.
-
ModelCardFilter (common/dto/manager/v2/model_card/request.py) has no vfolder_id filter, so even an indirect lookup via model card search by vfolder ID is impossible.
-
Clients today must list all model cards in a project and match by vfolder_id field on the client side.
Goal
Add a model_card field to VFolderGQL that returns the linked ModelCardGQL | None, mirroring the existing ModelCardGQL.vfolder resolver.
Scope
-
Add a ModelCardLoader (or extend an existing data loader) keyed by vfolder_id to avoid N+1.
-
Add model_card field on VFolderGQL using strawberry.lazy() for the cross-entity reference.
-
Update VFolderNode REST v2 DTO if parity is desired (optional - GQL-first is acceptable).
-
Add tests covering: vfolder with no card, vfolder with card, RBAC visibility (caller can see vfolder but not the card).
Out of scope
References
-
api/gql/CLAUDE.md — N+1 prevention rule, lazy import pattern.
-
api/gql/model_card/types.py:221-235 — existing forward-direction resolver as reference.
JIRA Issue: BA-5947
Background
ModelCardGQL.vfolderexposes the linked VFolder from a model card (api/gql/model_card/types.py:221-235), but the reverse direction is not exposed. There is no way to obtain the matching model card from a vfolder via either REST v2 or GraphQL.Findings:
VFolderGQL(api/gql/vfolder_v2/types/node.py) has no model_card field.VFolderNodeREST v2 DTO (common/dto/manager/v2/vfolder/response.py:57) has no model_card field.ModelCardFilter(common/dto/manager/v2/model_card/request.py) has novfolder_idfilter, so even an indirect lookup via model card search by vfolder ID is impossible.Clients today must list all model cards in a project and match by
vfolder_idfield on the client side.Goal
Add a
model_cardfield toVFolderGQLthat returns the linkedModelCardGQL | None, mirroring the existingModelCardGQL.vfolderresolver.Scope
Add a
ModelCardLoader(or extend an existing data loader) keyed byvfolder_idto avoid N+1.Add
model_cardfield onVFolderGQLusingstrawberry.lazy()for the cross-entity reference.Update
VFolderNodeREST v2 DTO if parity is desired (optional - GQL-first is acceptable).Add tests covering: vfolder with no card, vfolder with card, RBAC visibility (caller can see vfolder but not the card).
Out of scope
Adding
vfolder_idfilter toModelCardFilter(separate concern).REST v2 inline expansion (can be added later if demand arises).
References
api/gql/CLAUDE.md— N+1 prevention rule, lazy import pattern.api/gql/model_card/types.py:221-235— existing forward-direction resolver as reference.JIRA Issue: BA-5947