Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/46.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`execute_graphql` method for InfrahubClient(Sync) now properly considers the `default_branch` setting
2 changes: 2 additions & 0 deletions infrahub_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ async def execute_graphql(
_type_: _description_
"""

branch_name = branch_name or self.default_branch
url = self._graphql_url(branch_name=branch_name, at=at)

payload: dict[str, Union[str, dict]] = {"query": query}
Expand Down Expand Up @@ -1112,6 +1113,7 @@ def execute_graphql(
dict: The result of the GraphQL query or mutation.
"""

branch_name = branch_name or self.default_branch
url = self._graphql_url(branch_name=branch_name, at=at)

payload: dict[str, Union[str, dict]] = {"query": query}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/sdk/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1958,25 +1958,25 @@ async def mock_rest_api_artifact_generate(httpx_mock: HTTPXMock) -> HTTPXMock:
@pytest.fixture
async def mock_query_mutation_schema_dropdown_add(httpx_mock: HTTPXMock) -> None:
response = {"data": {"SchemaDropdownAdd": {"ok": True}}}
httpx_mock.add_response(method="POST", url="http://mock/graphql", json=response)
httpx_mock.add_response(method="POST", url="http://mock/graphql/main", json=response)


@pytest.fixture
async def mock_query_mutation_schema_dropdown_remove(httpx_mock: HTTPXMock) -> None:
response = {"data": {"SchemaDropdownRemove": {"ok": True}}}
httpx_mock.add_response(method="POST", url="http://mock/graphql", json=response)
httpx_mock.add_response(method="POST", url="http://mock/graphql/main", json=response)


@pytest.fixture
async def mock_query_mutation_schema_enum_add(httpx_mock: HTTPXMock) -> None:
response = {"data": {"SchemaEnumAdd": {"ok": True}}}
httpx_mock.add_response(method="POST", url="http://mock/graphql", json=response)
httpx_mock.add_response(method="POST", url="http://mock/graphql/main", json=response)


@pytest.fixture
async def mock_query_mutation_schema_enum_remove(httpx_mock: HTTPXMock) -> None:
response = {"data": {"SchemaEnumRemove": {"ok": True}}}
httpx_mock.add_response(method="POST", url="http://mock/graphql", json=response)
httpx_mock.add_response(method="POST", url="http://mock/graphql/main", json=response)


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/sdk/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ async def test_allocate_next_ip_prefix(
assert ip_prefix.description.value == "test"


EXPECTED_ECHO = """URL: http://mock/graphql
EXPECTED_ECHO = """URL: http://mock/graphql/main
QUERY:

query GetTags($name: String!) {
Expand Down