no-datetime-scalar
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
from httpx import AsyncClient
|
||||
|
||||
from settings import API_BASE
|
||||
@@ -22,8 +24,14 @@ async def get_author(author_id):
|
||||
if response.status_code != 200:
|
||||
return None
|
||||
r = response.json()
|
||||
author: ChatMember | None = r.get("data", {}).get("getAuthorById")
|
||||
return author
|
||||
a = r.get("data", {}).get("getAuthorById")
|
||||
if a:
|
||||
last_seen = a.get("lastSeen")
|
||||
dt = datetime.strptime(last_seen, "%Y-%m-%dT%H:%M:%S.%f")
|
||||
timestamp = int(dt.timestamp())
|
||||
a["lastSeen"] = timestamp
|
||||
author: ChatMember = a
|
||||
return author
|
||||
|
||||
|
||||
async def get_network(author_id: int, limit: int = 50, offset: int = 0) -> list:
|
||||
|
@@ -1,15 +1,9 @@
|
||||
from ariadne import ScalarType, QueryType, MutationType
|
||||
from ariadne import QueryType, MutationType
|
||||
|
||||
datetime_scalar = ScalarType("DateTime")
|
||||
query = QueryType()
|
||||
mutation = MutationType()
|
||||
|
||||
|
||||
@datetime_scalar.serializer
|
||||
def serialize_datetime(value):
|
||||
return value.isoformat()
|
||||
|
||||
|
||||
@query.field("_service")
|
||||
def resolve_service(*_):
|
||||
# Load the full SDL from your SDL file
|
||||
@@ -19,4 +13,4 @@ def resolve_service(*_):
|
||||
return {"sdl": full_sdl}
|
||||
|
||||
|
||||
resolvers = [query, mutation, datetime_scalar]
|
||||
resolvers = [query, mutation]
|
||||
|
Reference in New Issue
Block a user