Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HFID when using generic relationship attributes #4238

Merged
merged 2 commits into from
Sep 2, 2024
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 python_sdk/changelog/3900.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix fetching relationship attributes when relationship inherits from a generic
24 changes: 5 additions & 19 deletions python_sdk/infrahub_sdk/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Loading