debug-auth
All checks were successful
deploy / deploy (push) Successful in 1m3s

This commit is contained in:
Untone 2023-12-18 02:34:10 +03:00
parent 65a6d534c6
commit 3b08d5d6c7

View File

@ -10,20 +10,14 @@ headers = {"Content-Type": "application/json"}
async def _request_endpoint(query_name, body) -> Any:
async with aiohttp.ClientSession() as session:
try:
async with session.post(API_BASE, headers=headers, json=body) as response:
print(f"[services.core] {query_name}: [{response.status}] {len(await response.text())} bytes")
if response.status != 200:
return []
async with session.post(API_BASE, headers=headers, json=body) as response:
print(f"[services.core] {query_name} response: <{response.status}> {await response.text()}")
if response.status == 200:
r = await response.json()
if r:
return r.get("data", {}).get(query_name, {})
else:
raise Exception("json response error")
except Exception:
import traceback
traceback.print_exc()
print(f"[services.core] json response error {r}")
return []
async def get_all_authors() -> List[ChatMember]:
@ -88,4 +82,4 @@ async def get_author(author_id: int = None, slug: str = "", user: str = ""):
"variables": None if vars == {} else vars,
}
return await _request_endpoint(query_name, gql)
r = await _request_endpoint(query_name, gql)