@@ -539,6 +539,7 @@ async def _process_nodes_and_relationships(
539539 schema_kind : str ,
540540 branch : str ,
541541 prefetch_relationships : bool ,
542+ include : list [str ] | None ,
542543 timeout : int | None = None ,
543544 ) -> ProcessRelationsNode :
544545 """Processes InfrahubNode and their Relationships from the GraphQL query response.
@@ -563,9 +564,12 @@ async def _process_nodes_and_relationships(
563564 node = await InfrahubNode .from_graphql (client = self , branch = branch , data = item , timeout = timeout )
564565 nodes .append (node )
565566
566- if prefetch_relationships :
567+ if prefetch_relationships or ( include and any ( rel in include for rel in node . _relationships )) :
567568 await node ._process_relationships (
568- node_data = item , branch = branch , related_nodes = related_nodes , timeout = timeout
569+ node_data = item ,
570+ branch = branch ,
571+ related_nodes = related_nodes ,
572+ timeout = timeout ,
569573 )
570574
571575 return ProcessRelationsNode (nodes = nodes , related_nodes = related_nodes )
@@ -815,6 +819,7 @@ async def process_page(page_offset: int, page_number: int) -> tuple[dict, Proces
815819 branch = branch ,
816820 prefetch_relationships = prefetch_relationships ,
817821 timeout = timeout ,
822+ include = include ,
818823 )
819824 return response , process_result
820825
@@ -1829,6 +1834,7 @@ def _process_nodes_and_relationships(
18291834 schema_kind : str ,
18301835 branch : str ,
18311836 prefetch_relationships : bool ,
1837+ include : list [str ] | None ,
18321838 timeout : int | None = None ,
18331839 ) -> ProcessRelationsNodeSync :
18341840 """Processes InfrahubNodeSync and their Relationships from the GraphQL query response.
@@ -1853,7 +1859,7 @@ def _process_nodes_and_relationships(
18531859 node = InfrahubNodeSync .from_graphql (client = self , branch = branch , data = item , timeout = timeout )
18541860 nodes .append (node )
18551861
1856- if prefetch_relationships :
1862+ if prefetch_relationships or ( include and any ( rel in include for rel in node . _relationships )) :
18571863 node ._process_relationships (node_data = item , branch = branch , related_nodes = related_nodes , timeout = timeout )
18581864
18591865 return ProcessRelationsNodeSync (nodes = nodes , related_nodes = related_nodes )
@@ -1978,6 +1984,7 @@ def process_page(page_offset: int, page_number: int) -> tuple[dict, ProcessRelat
19781984 branch = branch ,
19791985 prefetch_relationships = prefetch_relationships ,
19801986 timeout = timeout ,
1987+ include = include ,
19811988 )
19821989 return response , process_result
19831990
0 commit comments