mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
feature(jobs): add subscription endpoint
This commit is contained in:
parent
f14866bdbc
commit
ed777e3ebf
0
selfprivacy_api/graphql/subscriptions/__init__.py
Normal file
0
selfprivacy_api/graphql/subscriptions/__init__.py
Normal file
20
selfprivacy_api/graphql/subscriptions/jobs.py
Normal file
20
selfprivacy_api/graphql/subscriptions/jobs.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# pylint: disable=too-few-public-methods
|
||||
import strawberry
|
||||
|
||||
from typing import AsyncGenerator, List
|
||||
|
||||
from selfprivacy_api.jobs import job_notifications
|
||||
|
||||
from selfprivacy_api.graphql.common_types.jobs import ApiJob
|
||||
from selfprivacy_api.graphql.queries.jobs import get_all_jobs
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class JobSubscriptions:
|
||||
"""Subscriptions related to jobs"""
|
||||
|
||||
@strawberry.subscription
|
||||
async def job_updates(self) -> AsyncGenerator[List[ApiJob], None]:
|
||||
# Send the complete list of jobs every time anything gets updated
|
||||
async for notification in job_notifications():
|
||||
yield get_all_jobs()
|
Loading…
Reference in a new issue