no-datetime-scalar
This commit is contained in:
parent
34dd4ec140
commit
4e44e2f39e
|
@ -3,6 +3,7 @@
|
||||||
- validators added
|
- validators added
|
||||||
- fixed graphql requests for core api
|
- fixed graphql requests for core api
|
||||||
- uses official redis[hiredis] async
|
- uses official redis[hiredis] async
|
||||||
|
- datetime scalar removed
|
||||||
|
|
||||||
[0.2.12]
|
[0.2.12]
|
||||||
- sigil is back for test
|
- sigil is back for test
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
scalar DateTime
|
|
||||||
|
|
||||||
type _Service {
|
type _Service {
|
||||||
sdl: String
|
sdl: String
|
||||||
}
|
}
|
||||||
|
@ -15,7 +13,7 @@ type ChatMember {
|
||||||
slug: String!
|
slug: String!
|
||||||
name: String!
|
name: String!
|
||||||
userpic: String
|
userpic: String
|
||||||
lastSeen: DateTime
|
lastSeen: Int!
|
||||||
online: Boolean
|
online: Boolean
|
||||||
# invitedAt: DateTime
|
# invitedAt: DateTime
|
||||||
# invitedBy: String # user slug
|
# invitedBy: String # user slug
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from httpx import AsyncClient
|
from httpx import AsyncClient
|
||||||
|
|
||||||
from settings import API_BASE
|
from settings import API_BASE
|
||||||
|
@ -22,7 +24,13 @@ async def get_author(author_id):
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return None
|
return None
|
||||||
r = response.json()
|
r = response.json()
|
||||||
author: ChatMember | None = r.get("data", {}).get("getAuthorById")
|
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
|
return author
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
from ariadne import ScalarType, QueryType, MutationType
|
from ariadne import QueryType, MutationType
|
||||||
|
|
||||||
datetime_scalar = ScalarType("DateTime")
|
|
||||||
query = QueryType()
|
query = QueryType()
|
||||||
mutation = MutationType()
|
mutation = MutationType()
|
||||||
|
|
||||||
|
|
||||||
@datetime_scalar.serializer
|
|
||||||
def serialize_datetime(value):
|
|
||||||
return value.isoformat()
|
|
||||||
|
|
||||||
|
|
||||||
@query.field("_service")
|
@query.field("_service")
|
||||||
def resolve_service(*_):
|
def resolve_service(*_):
|
||||||
# Load the full SDL from your SDL file
|
# Load the full SDL from your SDL file
|
||||||
|
@ -19,4 +13,4 @@ def resolve_service(*_):
|
||||||
return {"sdl": full_sdl}
|
return {"sdl": full_sdl}
|
||||||
|
|
||||||
|
|
||||||
resolvers = [query, mutation, datetime_scalar]
|
resolvers = [query, mutation]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user