Skip to content

Commit

Permalink
fix: bubble up TransportQueryError
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufhm committed Jul 19, 2024
1 parent d6de050 commit 6a45c83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions api/plugins/action/fact.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def get_facts(client: GqlClient, environment_id):
)

try:
if "error" in res:
return res
return res["environmentById"]["facts"]
except KeyError:
return dict()
except:
raise


def delete_fact(client: GqlClient, environment_id, name):
Expand Down Expand Up @@ -136,6 +136,9 @@ def run(self, tmp=None, task_vars=None):
found_fact = False

facts = get_facts(self.client, environment_id)
if "error" in facts:
raise facts["error"]

for fact in facts:
if fact["name"] == name:
found_fact = fact
Expand Down
3 changes: 2 additions & 1 deletion api/plugins/module_utils/gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def execute_query(self, query: str, variables: Optional[Dict[str, Any]]={}) -> D
self.vvvv(f"GraphQL query result: {res}")
return res
except TransportQueryError as e:
return e
self.vvvv(f"GraphQL TransportQueryError: {e}")
return {'error': e}

def build_dynamic_query(self, query: str, mainType: str, args: Optional[Dict[str, Any]] = {}, fields: List[str] = [], subFieldsMap: Optional[Dict[str, List[str]]] = {}) -> DSLField:
"""
Expand Down

0 comments on commit 6a45c83

Please sign in to comment.