diff --git a/.github/file-filters.yml b/.github/file-filters.yml index c0b9bb34..5bad4df4 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -1,13 +1,16 @@ --- +# A bad edit to a workflow or to this filter file can silently skip jobs, so +# every filter below folds in *ci_config: any change to the CI plumbing runs the +# full pipeline. ci_config: &ci_config - - ".github/workflows/ci.yml" + - ".github/workflows/**" - ".github/file-filters.yml" coverage_config: &coverage_config - "codecov.yml" github_workflows: &github_workflows - - ".github/workflows/*.yml" + - *ci_config development_files: &development_files - "development/**" @@ -43,6 +46,8 @@ documentation_all: - *development_files - *doc_files - *markdown_all + - *ci_config documentation_generated_all: - *infrahub_reference_generated + - *ci_config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57555d57..1cd96ed8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -194,7 +194,7 @@ jobs: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && - (needs.files-changed.outputs.python == 'true') || (needs.files-changed.outputs.documentation_generated == 'true') + (needs.files-changed.outputs.python == 'true' || needs.files-changed.outputs.documentation_generated == 'true') needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"] runs-on: "ubuntu-22.04" timeout-minutes: 5 diff --git a/changelog/+relationship-peer-count.fixed.md b/changelog/+relationship-peer-count.fixed.md new file mode 100644 index 00000000..66b4a048 --- /dev/null +++ b/changelog/+relationship-peer-count.fixed.md @@ -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. diff --git a/infrahub_sdk/node/relationship.py b/infrahub_sdk/node/relationship.py index 7069b13e..405b9215 100644 --- a/infrahub_sdk/node/relationship.py +++ b/infrahub_sdk/node/relationship.py @@ -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}}, } diff --git a/tests/unit/sdk/test_node.py b/tests/unit/sdk/test_node.py index d8c73563..bdc01744 100644 --- a/tests/unit/sdk/test_node.py +++ b/tests/unit/sdk/test_node.py @@ -1250,7 +1250,6 @@ async def test_query_data_include_property( }, }, "tags": { - "count": None, "edges": { "properties": { "is_protected": None, @@ -1324,7 +1323,6 @@ async def test_query_data_include( }, }, "tags": { - "count": None, "edges": { "node": { "id": None, @@ -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 @@ -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"]