Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/+relationship-peer-count.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The queries generated by `all()`, `filters()`, `get()` and relationship `fetch()` no longer request `count` on cardinality-many relationships. The SDK never read that value, and Infrahub resolved it with one extra database query per returned node and per relationship, on top of preventing the peer reads of those nodes from being batched into a single query.
3 changes: 1 addition & 2 deletions infrahub_sdk/node/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ def _generate_query_data(

Returns:
Dict: A dictionary representing the basic structure of a GraphQL query for multiple related nodes.
It includes count, edges, and node information (ID, display label, and typename), along with additional properties
It includes edges and node information (ID, display label, and typename), along with additional properties
and any peer_data provided.

"""
data: dict[str, Any] = {
"count": None,
"edges": {"node": {"id": None, "hfid": None, "display_label": None, "__typename": None}},
}

Expand Down
6 changes: 2 additions & 4 deletions tests/unit/sdk/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,6 @@ async def test_query_data_include_property(
},
},
"tags": {
"count": None,
"edges": {
"properties": {
"is_protected": None,
Expand Down Expand Up @@ -1324,7 +1323,6 @@ async def test_query_data_include(
},
},
"tags": {
"count": None,
"edges": {
"node": {
"id": None,
Expand Down Expand Up @@ -3062,7 +3060,7 @@ def test_relationship_manager_generate_query_data_with_include_metadata() -> Non
"""Test that RelationshipManagerBase._generate_query_data includes metadata when include_metadata=True."""
data = RelationshipManagerBase._generate_query_data(include_metadata=True)

assert "count" in data
assert "count" not in data
assert "edges" in data
assert "node" in data["edges"]
assert data["edges"]["node"]["id"] is None
Expand Down Expand Up @@ -3108,7 +3106,7 @@ def test_relationship_manager_generate_query_data_without_include_metadata() ->
assert "node_metadata" not in data["edges"]
assert "relationship_metadata" not in data["edges"]

assert "count" in data
assert "count" not in data
assert "edges" in data
assert "node" in data["edges"]

Expand Down