46 lines
901 B
Python
46 lines
901 B
Python
|
from .chats import chats_resolvers
|
||
|
from .load import load_resolvers
|
||
|
from .messages import messages_resolvers
|
||
|
from .search import search_resolvers
|
||
|
from .unread import unread_resolvers
|
||
|
import json
|
||
|
from ariadne import MutationType, QueryType, SubscriptionType
|
||
|
from ariadne import ScalarType
|
||
|
|
||
|
|
||
|
datetime_scalar = ScalarType("DateTime")
|
||
|
|
||
|
|
||
|
@datetime_scalar.serializer
|
||
|
def serialize_datetime(value):
|
||
|
return value.isoformat()
|
||
|
|
||
|
|
||
|
query = QueryType()
|
||
|
mutation = MutationType()
|
||
|
subscription = SubscriptionType()
|
||
|
|
||
|
|
||
|
dict_scalar = ScalarType("Dict")
|
||
|
|
||
|
|
||
|
@dict_scalar.serializer
|
||
|
def serialize_dict(value):
|
||
|
return json.dumps(value)
|
||
|
|
||
|
|
||
|
@dict_scalar.value_parser
|
||
|
def parse_dict_value(value):
|
||
|
return json.loads(value)
|
||
|
|
||
|
|
||
|
resolvers = {
|
||
|
**chats_resolvers,
|
||
|
**load_resolvers,
|
||
|
**messages_resolvers,
|
||
|
**search_resolvers,
|
||
|
**unread_resolvers,
|
||
|
"DateTime": datetime_scalar,
|
||
|
"Dict": dict_scalar,
|
||
|
}
|