From 0e73b7489d1e63f58c29064a0d0eb2befbbcbeab Mon Sep 17 00:00:00 2001 From: user2589 Date: Fri, 25 Sep 2020 22:27:45 -0400 Subject: [PATCH] fix: raise on error in graphql queries --- stscraper/base.py | 2 +- stscraper/github.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stscraper/base.py b/stscraper/base.py index bef6671..cdec502 100644 --- a/stscraper/base.py +++ b/stscraper/base.py @@ -90,7 +90,7 @@ def json_path(obj, path, raise_on_missing=False): obj = ",".join(str(item.get(chunk[1:])) for item in obj) # supported only for the last chunk in the path, so break break - if chunk not in obj: + if obj is None or chunk not in obj: if raise_on_missing: raise IndexError('Path does not exist') else: diff --git a/stscraper/github.py b/stscraper/github.py index d7997e4..024f94a 100644 --- a/stscraper/github.py +++ b/stscraper/github.py @@ -361,8 +361,8 @@ class will help you with pagination and network timeouts. {'login': 'neoascetic'}] In the first case, it will return a dictionary of user attributes. - In the second case, it will return a generator of repository issue objects, - handling the pagination transparently. + In the second case, it will return a generator of objects, handling + pagination transparently. It looks a little bit like magic, but it is not. Here is how it works: @@ -441,7 +441,7 @@ def v4(self, query, object_path=None, **params): return res = self.extract_result(r) - if 'data' not in res: + if 'errors' in res or 'data' not in res: raise VCSError('API didn\'t return any data:\n' + json.dumps(res, indent=4)) data = res['data']