drugs/core/clients/graphql.py

27 lines
623 B
Python
Raw Normal View History

2024-01-15 15:29:33 +00:00
from abc import ABC
from core.models import Source
from core.util import logs
log = logs.get_logger("graphql")
class GraphQLClient(ABC):
"""
GraphQL API handler.
"""
async def connect(self):
try:
source = Source.objects.get(name=self.source_name)
except Source.DoesNotExist:
source = Source(
name=self.source_name,
type=self.source_type,
endpoint=self.source_endpoint,
score=self.source_score,
)
source.save()
self.url = source.endpoint
self.source = source