2021-07-27 04:58:06 +00:00
|
|
|
from orm import Shout, User
|
|
|
|
from orm.base import global_session
|
|
|
|
|
|
|
|
from resolvers.base import mutation, query, subscription
|
|
|
|
|
2021-07-27 05:41:45 +00:00
|
|
|
@query.field("topShouts")
|
|
|
|
async def top_shouts(_, info: GraphQLResolveInfo):
|
|
|
|
# TODO: implement top shouts
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@query.field("topAuthors")
|
|
|
|
async def top_shouts(_, info: GraphQLResolveInfo):
|
|
|
|
# TODO: implement top authors
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2021-07-27 04:58:06 +00:00
|
|
|
# TODO: debug me
|
|
|
|
@mutation.field("createShout")
|
|
|
|
@login_required
|
|
|
|
async def create_post(_, info, input):
|
|
|
|
auth = info.context["request"].auth
|
|
|
|
user_id = auth.user_id
|
|
|
|
|
|
|
|
new_shout = Shout.create(
|
|
|
|
author = user_id,
|
|
|
|
body = input["body"], # TODO: add createShoutInput in scheme.graphql
|
|
|
|
title = input.get("title")
|
|
|
|
# TODO: generate slug
|
|
|
|
)
|
|
|
|
|
|
|
|
return {
|
|
|
|
"status": True,
|
|
|
|
"shout" : new_shout
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: paginate, get, update, delete
|