def gql(query, variables): url = config['GraphQL']['url'] secret = config['GraphQL']['secret'] headers = { 'Content-Type': 'application/json', 'x-hasura-admin-secret': '%s' % secret } my_session = retry(retries=10) r = my_session.post(url, json={ 'query': query, 'variables': variables }, headers=headers) if r.status_code == 200: r_json = json.loads(r.text) logging.debug("Response" + str(r_json)) else: raise Exception( "Query failed to run by returning code of {}. {}".format( requests.status_code, query)) return r.text
def get(url): session = retry(Session(), retries=10, backoff_factor=0.2) ret = session.get(url) while ret.status_code != 200: ret = session.get(url) return ret