webhook-add
All checks were successful
Deploy on push / deploy (push) Successful in 7s

This commit is contained in:
2024-12-11 22:07:36 +03:00
parent 6762b18135
commit fe93439194
3 changed files with 62 additions and 25 deletions

View File

@@ -1,5 +1,31 @@
from asyncio.log import logger
from ariadne import MutationType, QueryType
import httpx
from settings import AUTH_URL
query = QueryType()
mutation = MutationType()
resolvers = [query, mutation]
async def request_graphql_data(gql, url=AUTH_URL, headers=None):
if headers is None:
headers = {"Content-Type": "application/json"}
try:
# logger.debug(f"{url} {gql} {headers}")
async with httpx.AsyncClient() as client:
response = await client.post(url, json=gql, headers=headers)
if response.status_code == 200:
data = response.json()
errors = data.get("errors")
if errors:
logger.error(f"{url} response: {data}")
else:
return data
except Exception as _e:
# Handling and logging exceptions during authentication check
import traceback
logger.error(f"request_graphql_data error: {traceback.format_exc()}")
return None