Skip to content

Commit

Permalink
ChainGraph now includes node types
Browse files Browse the repository at this point in the history
  • Loading branch information
kreneskyp committed Aug 8, 2023
1 parent 20c5c16 commit 7c67380
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ix/api/chains/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class GraphModel(BaseModel):
chain: ChainPydantic
nodes: List[NodePydantic]
edges: List[EdgePydantic]
types: List[NodeTypePydantic]


@router.get("/chains/{chain_id}/graph", response_model=GraphModel, tags=["Chains"])
Expand All @@ -306,8 +307,12 @@ async def get_chain_graph(chain_id: UUID):
async for edge in edge_queryset:
edges.append(EdgePydantic.from_orm(edge))

types_in_chain = NodeType.objects.filter(chainnode__chain_id=chain_id)
types = [NodeTypePydantic.from_orm(node_type) async for node_type in types_in_chain]

return GraphModel(
chain=ChainPydantic.from_orm(chain),
nodes=nodes,
edges=edges,
types=types,
)

0 comments on commit 7c67380

Please sign in to comment.