Skip to content

Commit 261a13e

Browse files
committed
Make raise_for_error optional
1 parent 25a32a2 commit 261a13e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

infrahub_sdk/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ async def execute_graphql(
882882
branch_name: str | None = None,
883883
at: str | Timestamp | None = None,
884884
timeout: int | None = None,
885-
raise_for_error: bool = True,
885+
raise_for_error: bool | None = None,
886886
tracker: str | None = None,
887887
) -> dict:
888888
"""Execute a GraphQL query (or mutation).
@@ -902,9 +902,9 @@ async def execute_graphql(
902902
Returns:
903903
_type_: _description_
904904
"""
905-
if not raise_for_error:
905+
if raise_for_error is not None:
906906
warnings.warn(
907-
"Setting `raise_for_error=False` is deprecated, use `try/except` to handle errors.",
907+
"Using `raise_for_error` is deprecated, use `try/except` to handle errors.",
908908
DeprecationWarning,
909909
stacklevel=1,
910910
)
@@ -930,7 +930,7 @@ async def execute_graphql(
930930
try:
931931
resp = await self._post(url=url, payload=payload, headers=headers, timeout=timeout)
932932

933-
if raise_for_error:
933+
if raise_for_error in (None, True):
934934
resp.raise_for_status()
935935

936936
retry = False
@@ -1633,7 +1633,7 @@ def execute_graphql(
16331633
branch_name: str | None = None,
16341634
at: str | Timestamp | None = None,
16351635
timeout: int | None = None,
1636-
raise_for_error: bool = True,
1636+
raise_for_error: bool | None = None,
16371637
tracker: str | None = None,
16381638
) -> dict:
16391639
"""Execute a GraphQL query (or mutation).
@@ -1653,9 +1653,9 @@ def execute_graphql(
16531653
Returns:
16541654
dict: The result of the GraphQL query or mutation.
16551655
"""
1656-
if not raise_for_error:
1656+
if raise_for_error is not None:
16571657
warnings.warn(
1658-
"Setting `raise_for_error=False` is deprecated, use `try/except` to handle errors.",
1658+
"Using `raise_for_error` is deprecated, use `try/except` to handle errors.",
16591659
DeprecationWarning,
16601660
stacklevel=1,
16611661
)
@@ -1681,7 +1681,7 @@ def execute_graphql(
16811681
try:
16821682
resp = self._post(url=url, payload=payload, headers=headers, timeout=timeout)
16831683

1684-
if raise_for_error:
1684+
if raise_for_error in (None, True):
16851685
resp.raise_for_status()
16861686

16871687
retry = False

0 commit comments

Comments
 (0)