authorid-context
All checks were successful
deploy / deploy (push) Successful in 1m18s

This commit is contained in:
2023-11-28 19:04:45 +03:00
parent 2d89a4ec86
commit 68fce283bc
10 changed files with 47 additions and 300 deletions

View File

@@ -1,9 +1,5 @@
from typing import List
from typing import List, Any
from httpx import AsyncClient
from orm.author import Author
from orm.shout import Shout
from settings import API_BASE
headers = {"Content-Type": "application/json"}
@@ -27,22 +23,7 @@ async def _request_endpoint(query_name, body):
traceback.print_exc()
async def get_author(author_id) -> Author:
query_name = "get_author"
query_type = "query"
operation = "GetAuthor"
query_fields = "id slug pic name"
gql = {
"query": query_type + " " + operation + " { " + query_name + " { " + query_fields + "} " + " }",
"operationName": operation,
"variables": None,
}
return await _request_endpoint(query_name, gql)
async def get_followed_shouts(author_id: int) -> List[Shout]:
async def get_followed_shouts(author_id: int) -> List[Any]:
query_name = "load_shouts_followed"
query_type = "query"
operation = "GetFollowedShouts"
@@ -55,7 +36,7 @@ async def get_followed_shouts(author_id: int) -> List[Shout]:
body = {
"query": query,
"operationName": operation,
"variables": {"author_id": author_id, "limit": 1000, "offset": 0}, # FIXME: too big
"variables": {"author_id": author_id, "limit": 1000, "offset": 0}, # FIXME: too big limit
}
return await _request_endpoint(query_name, body)