This commit is contained in:
parent
65a6d534c6
commit
3b08d5d6c7
|
@ -10,20 +10,14 @@ headers = {"Content-Type": "application/json"}
|
||||||
|
|
||||||
async def _request_endpoint(query_name, body) -> Any:
|
async def _request_endpoint(query_name, body) -> Any:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
try:
|
async with session.post(API_BASE, headers=headers, json=body) as response:
|
||||||
async with session.post(API_BASE, headers=headers, json=body) as response:
|
print(f"[services.core] {query_name} response: <{response.status}> {await response.text()}")
|
||||||
print(f"[services.core] {query_name}: [{response.status}] {len(await response.text())} bytes")
|
if response.status == 200:
|
||||||
if response.status != 200:
|
|
||||||
return []
|
|
||||||
r = await response.json()
|
r = await response.json()
|
||||||
if r:
|
if r:
|
||||||
return r.get("data", {}).get(query_name, {})
|
return r.get("data", {}).get(query_name, {})
|
||||||
else:
|
print(f"[services.core] json response error {r}")
|
||||||
raise Exception("json response error")
|
return []
|
||||||
except Exception:
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
|
|
||||||
async def get_all_authors() -> List[ChatMember]:
|
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,
|
"variables": None if vars == {} else vars,
|
||||||
}
|
}
|
||||||
|
|
||||||
return await _request_endpoint(query_name, gql)
|
r = await _request_endpoint(query_name, gql)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user