Skip to content

Commit 4dde424

Browse files
committed
Respect default branch for client.query_gql_query()
1 parent 482c969 commit 4dde424

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

changelog/236.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Respect default branch for client.query_gql_query() and client.set_context_properties()

infrahub_sdk/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def set_context_properties(
209209
delete_unused_nodes=delete_unused_nodes,
210210
group_type=group_type,
211211
group_params=group_params,
212-
branch=branch,
212+
branch=branch or self.default_branch,
213213
)
214214

215215
def _graphql_url(
@@ -1103,13 +1103,13 @@ async def query_gql_query(
11031103
) -> dict:
11041104
url = f"{self.address}/api/query/{name}"
11051105
url_params = copy.deepcopy(params or {})
1106+
url_params["branch"] = branch_name or self.default_branch
1107+
11061108
headers = copy.copy(self.headers or {})
11071109

11081110
if self.insert_tracker and tracker:
11091111
headers["X-Infrahub-Tracker"] = tracker
11101112

1111-
if branch_name:
1112-
url_params["branch"] = branch_name
11131113
if at:
11141114
url_params["at"] = at
11151115

@@ -2242,13 +2242,13 @@ def query_gql_query(
22422242
) -> dict:
22432243
url = f"{self.address}/api/query/{name}"
22442244
url_params = copy.deepcopy(params or {})
2245+
url_params["branch"] = branch_name or self.default_branch
2246+
22452247
headers = copy.copy(self.headers or {})
22462248

22472249
if self.insert_tracker and tracker:
22482250
headers["X-Infrahub-Tracker"] = tracker
22492251

2250-
if branch_name:
2251-
url_params["branch"] = branch_name
22522252
if at:
22532253
url_params["at"] = at
22542254
if subscribers:

0 commit comments

Comments
 (0)