-
Notifications
You must be signed in to change notification settings - Fork 6
Fix filters include parameter
#513
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -742,12 +742,11 @@ async def generate_query_data_node( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| peer_data: dict[str, Any] = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if rel_schema and prefetch_relationships: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| should_fetch_relationship = prefetch_relationships or (include is not None and rel_name in include) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if rel_schema and should_fetch_relationship: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| property=property, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
744
to
752
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Async nested prefetch should propagate include/exclude (filtered) to match sync semantics and avoid over/under-fetch. Currently only Apply: - peer_data = await peer_node.generate_query_data_node(
- property=property,
- )
+ # Propagate only relationship names relevant to the peer schema
+ peer_rel_names = getattr(peer_schema, "relationship_names", [r.name for r in peer_schema.relationships])
+ child_include = [n for n in (include or []) if n in peer_rel_names] or None
+ child_exclude = [n for n in (exclude or []) if n in peer_rel_names] or None
+ peer_data = await peer_node.generate_query_data_node(
+ include=child_include,
+ exclude=child_exclude,
+ property=property,
+ )📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -886,7 +885,11 @@ async def update( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| await self._process_mutation_result(mutation_name=mutation_name, response=response, timeout=timeout) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def _process_relationships( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| self, node_data: dict[str, Any], branch: str, related_nodes: list[InfrahubNode], timeout: int | None = None | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| node_data: dict[str, Any], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| branch: str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| related_nodes: list[InfrahubNode], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeout: int | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Processes the Relationships of a InfrahubNode and add Related Nodes to a list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1363,7 +1366,8 @@ def generate_query_data_node( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| peer_data: dict[str, Any] = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if rel_schema and prefetch_relationships: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| should_fetch_relationship = prefetch_relationships or (include is not None and rel_name in include) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if rel_schema and should_fetch_relationship: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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, property=property) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was something like this I was thinking about in the comments above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had actually addressed these changes following Aaron's comment but didn't push them