Skip to content

Commit f4035f0

Browse files
authored
Merge pull request #518 from opsmill/pog-query-branch-IHS-89
Respect default branch for client.query_gql_query()
2 parents 17c1f6a + 4dde424 commit f4035f0

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(
@@ -1107,13 +1107,13 @@ async def query_gql_query(
11071107
) -> dict:
11081108
url = f"{self.address}/api/query/{name}"
11091109
url_params = copy.deepcopy(params or {})
1110+
url_params["branch"] = branch_name or self.default_branch
1111+
11101112
headers = copy.copy(self.headers or {})
11111113

11121114
if self.insert_tracker and tracker:
11131115
headers["X-Infrahub-Tracker"] = tracker
11141116

1115-
if branch_name:
1116-
url_params["branch"] = branch_name
11171117
if at:
11181118
url_params["at"] = at
11191119

@@ -2247,13 +2247,13 @@ def query_gql_query(
22472247
) -> dict:
22482248
url = f"{self.address}/api/query/{name}"
22492249
url_params = copy.deepcopy(params or {})
2250+
url_params["branch"] = branch_name or self.default_branch
2251+
22502252
headers = copy.copy(self.headers or {})
22512253

22522254
if self.insert_tracker and tracker:
22532255
headers["X-Infrahub-Tracker"] = tracker
22542256

2255-
if branch_name:
2256-
url_params["branch"] = branch_name
22572257
if at:
22582258
url_params["at"] = at
22592259
if subscribers:

0 commit comments

Comments
 (0)