diff --git a/changelog/236.fixed.md b/changelog/236.fixed.md new file mode 100644 index 00000000..510c0a58 --- /dev/null +++ b/changelog/236.fixed.md @@ -0,0 +1 @@ +Respect default branch for client.query_gql_query() and client.set_context_properties() diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index 4a6ad81b..8ace112a 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -209,7 +209,7 @@ def set_context_properties( delete_unused_nodes=delete_unused_nodes, group_type=group_type, group_params=group_params, - branch=branch, + branch=branch or self.default_branch, ) def _graphql_url( @@ -1103,13 +1103,13 @@ async def query_gql_query( ) -> dict: url = f"{self.address}/api/query/{name}" url_params = copy.deepcopy(params or {}) + url_params["branch"] = branch_name or self.default_branch + headers = copy.copy(self.headers or {}) if self.insert_tracker and tracker: headers["X-Infrahub-Tracker"] = tracker - if branch_name: - url_params["branch"] = branch_name if at: url_params["at"] = at @@ -2242,13 +2242,13 @@ def query_gql_query( ) -> dict: url = f"{self.address}/api/query/{name}" url_params = copy.deepcopy(params or {}) + url_params["branch"] = branch_name or self.default_branch + headers = copy.copy(self.headers or {}) if self.insert_tracker and tracker: headers["X-Infrahub-Tracker"] = tracker - if branch_name: - url_params["branch"] = branch_name if at: url_params["at"] = at if subscribers: