Skip to content

Commit 0351c74

Browse files
authored
Merge pull request #332 from opsmill/bkr-fix-process-nodes
Fixes process nodes for relation `None`
2 parents eda8705 + d26fbe0 commit 0351c74

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

changelog/331.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix node processing, when using fragment with `prefetch_relationships`.

infrahub_sdk/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,15 +1479,15 @@ async def _process_relationships(
14791479
for rel_name in self._relationships:
14801480
rel = getattr(self, rel_name)
14811481
if rel and isinstance(rel, RelatedNode):
1482-
relation = node_data["node"].get(rel_name)
1483-
if relation.get("node", None):
1482+
relation = node_data["node"].get(rel_name, None)
1483+
if relation and relation.get("node", None):
14841484
related_node = await InfrahubNode.from_graphql(
14851485
client=self._client, branch=branch, data=relation, timeout=timeout
14861486
)
14871487
related_nodes.append(related_node)
14881488
elif rel and isinstance(rel, RelationshipManager):
1489-
peers = node_data["node"].get(rel_name)
1490-
if peers:
1489+
peers = node_data["node"].get(rel_name, None)
1490+
if peers and peers["edges"]:
14911491
for peer in peers["edges"]:
14921492
related_node = await InfrahubNode.from_graphql(
14931493
client=self._client, branch=branch, data=peer, timeout=timeout

0 commit comments

Comments
 (0)