This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, List
|
||||
from typing import Any
|
||||
|
||||
import aiohttp
|
||||
|
||||
@@ -11,7 +11,7 @@ api_base = API_BASE or "https://core.discours.io"
|
||||
async def _request_endpoint(query_name, body) -> Any:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
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} HTTP Response {response.status} {await response.text()}")
|
||||
if response.status == 200:
|
||||
r = await response.json()
|
||||
if r:
|
||||
@@ -27,10 +27,23 @@ async def get_followed_shouts(author_id: int):
|
||||
{query_name}(author_id: $author_id, limit: $limit, offset: $offset) {{ id slug title }}
|
||||
}}"""
|
||||
|
||||
body = {
|
||||
gql = {
|
||||
"query": query,
|
||||
"operationName": operation,
|
||||
"variables": {"author_id": author_id, "limit": 1000, "offset": 0}, # FIXME: too big limit
|
||||
}
|
||||
|
||||
return await _request_endpoint(query_name, body)
|
||||
return await _request_endpoint(query_name, gql)
|
||||
|
||||
|
||||
async def get_shout(shout_id):
|
||||
query_name = "get_shout"
|
||||
operation = "GetShout"
|
||||
|
||||
query = f"""query {operation}($slug: String, $shout_id: Int) {{
|
||||
{query_name}(slug: $slug, shout_id: $shout_id) {{ id slug title authors {{ id slug name pic }} }}
|
||||
}}"""
|
||||
|
||||
gql = {"query": query, "operationName": operation, "variables": {"slug": None, "shout_id": shout_id}}
|
||||
|
||||
return await _request_endpoint(query_name, gql)
|
||||
|
Reference in New Issue
Block a user