diff --git a/changelog/query-parallel.fixed.md b/changelog/query-parallel.fixed.md new file mode 100644 index 0000000..e337ce9 --- /dev/null +++ b/changelog/query-parallel.fixed.md @@ -0,0 +1 @@ +fixes issue where using `parallel` query execution could lead to excessive and unneeded GraphQL queries diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index 839f1ec..826ae26 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -781,7 +781,7 @@ async def process_batch() -> tuple[list[InfrahubNode], list[InfrahubNode]]: nodes = [] related_nodes = [] batch_process = await self.create_batch() - count = await self.count(kind=schema.kind) + count = await self.count(kind=schema.kind, **filters) total_pages = (count + pagination_size - 1) // pagination_size for page_number in range(1, total_pages + 1): @@ -1920,7 +1920,7 @@ def process_batch() -> tuple[list[InfrahubNodeSync], list[InfrahubNodeSync]]: related_nodes = [] batch_process = self.create_batch() - count = self.count(kind=schema.kind) + count = self.count(kind=schema.kind, **filters) total_pages = (count + pagination_size - 1) // pagination_size for page_number in range(1, total_pages + 1):