From 36e7269b8db8dce0d9cd74e8dd682035c424ee73 Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Mon, 2 Sep 2024 10:20:05 +0200 Subject: [PATCH 1/2] Do not exclude generic's data for rels --- python_sdk/infrahub_sdk/node.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/python_sdk/infrahub_sdk/node.py b/python_sdk/infrahub_sdk/node.py index 77e6a91f6e..66b9bb0ff3 100644 --- a/python_sdk/infrahub_sdk/node.py +++ b/python_sdk/infrahub_sdk/node.py @@ -1067,11 +1067,7 @@ def __init__( @classmethod async def from_graphql( - cls, - client: InfrahubClient, - branch: str, - data: dict, - schema: Optional[MainSchemaTypes] = None, + cls, client: InfrahubClient, branch: str, data: dict, schema: Optional[MainSchemaTypes] = None ) -> Self: if not schema: node_kind = data.get("__typename", None) or data.get("node", {}).get("__typename", None) @@ -1279,7 +1275,7 @@ async def generate_query_data_node( if rel_schema and prefetch_relationships: peer_schema = await self._client.schema.get(kind=rel_schema.peer, branch=self._branch) peer_node = InfrahubNode(client=self._client, schema=peer_schema, branch=self._branch) - peer_data = await peer_node.generate_query_data_node(include=include, exclude=exclude, inherited=False) + peer_data = await peer_node.generate_query_data_node(include=include, exclude=exclude) if rel_schema and rel_schema.cardinality == "one": rel_data = RelatedNode._generate_query_data(peer_data=peer_data) @@ -1548,11 +1544,7 @@ def __init__( @classmethod def from_graphql( - cls, - client: InfrahubClientSync, - branch: str, - data: dict, - schema: Optional[MainSchemaTypes] = None, + cls, client: InfrahubClientSync, branch: str, data: dict, schema: Optional[MainSchemaTypes] = None ) -> Self: if not schema: node_kind = data.get("__typename", None) or data.get("node", {}).get("__typename", None) @@ -1752,7 +1744,7 @@ def generate_query_data_node( if rel_schema and prefetch_relationships: peer_schema = self._client.schema.get(kind=rel_schema.peer, branch=self._branch) peer_node = InfrahubNodeSync(client=self._client, schema=peer_schema, branch=self._branch) - peer_data = peer_node.generate_query_data_node(include=include, exclude=exclude, inherited=False) + peer_data = peer_node.generate_query_data_node(include=include, exclude=exclude) if rel_schema and rel_schema.cardinality == "one": rel_data = RelatedNodeSync._generate_query_data(peer_data=peer_data) @@ -2051,13 +2043,7 @@ def prop(self, value): # type: ignore setattr( self, internal_name, - node_class( - name=external_name, - branch=node._branch, - client=node._client, - schema=schema, - data=value, - ), + node_class(name=external_name, branch=node._branch, client=node._client, schema=schema, data=value), ) return prop From 8443035f40c073b96affd5c14fcafac093ac5f62 Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Mon, 2 Sep 2024 11:41:52 +0200 Subject: [PATCH 2/2] Add changelog fragment --- python_sdk/changelog/3900.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 python_sdk/changelog/3900.fixed.md diff --git a/python_sdk/changelog/3900.fixed.md b/python_sdk/changelog/3900.fixed.md new file mode 100644 index 0000000000..fa59604cfa --- /dev/null +++ b/python_sdk/changelog/3900.fixed.md @@ -0,0 +1 @@ +Fix fetching relationship attributes when relationship inherits from a generic \ No newline at end of file