initial topicUpdated

This commit is contained in:
knst-kotov 2021-11-04 19:37:41 +03:00
parent 7f8908a84b
commit e5aa568933
4 changed files with 29 additions and 13 deletions

0
create_crt.sh Executable file → Normal file
View File

View File

@ -16,3 +16,4 @@ transliterate
requests requests
bcrypt bcrypt
bs4 bs4
websockets

View File

@ -45,3 +45,18 @@ async def topic_unsubscribe(_, info, slug):
session.delete(sub) session.delete(sub)
return {} # type Result return {} # type Result
return { "error": "session error" } return { "error": "session error" }
@subscription.source("topicUpdated")
async def new_shout_generator(obj, info, user_id):
with local_session() as session:
topics = session.query(TopicSubscription.topic).filter(TopicSubscription.user == user_id).all()
#TODO filter new shouts
while True:
new_shout = {"slug": "slug", "body" : "body"}
yield new_shout
await asyncio.sleep(30)
print("end")
@subscription.field("topicUpdated")
def shout_resolver(shout, info, user_id):
return shout

View File

@ -129,7 +129,7 @@ type Subscription {
onlineUpdated: [User!]! onlineUpdated: [User!]!
shoutUpdated: Shout! shoutUpdated: Shout!
userUpdated: User! userUpdated: User!
topicUpdated: Shout! topicUpdated(user_id: Int!): Shout!
} }
############################################ Entities ############################################ Entities