mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-26 20:53:34 -08:00
27 lines
604 B
Python
27 lines
604 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
from httpx import AsyncClient, Client, Response
|
|
from typing_extensions import Counter
|
|
|
|
from .networking import TIMEOUT
|
|
|
|
|
|
def execute_graphql_query(
|
|
url: str, httpx_client: Client, graphql_file: Path, variables: dict
|
|
):
|
|
response = httpx_client.get(
|
|
url,
|
|
params={
|
|
"variables": json.dumps(variables),
|
|
"query": load_graphql_from_file(graphql_file),
|
|
},
|
|
timeout=TIMEOUT,
|
|
)
|
|
return response
|
|
|
|
|
|
def load_graphql_from_file(file: Path) -> str:
|
|
query = file.read_text(encoding="utf-8")
|
|
return query
|