Fix GetCatalog

This commit is contained in:
Ivan Vazhenin
2023-03-26 15:29:17 +03:00
parent 65c0b561a7
commit c2383140b6
12 changed files with 109 additions and 34 deletions

44
reqs/graphql.py Normal file
View File

@@ -0,0 +1,44 @@
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
transport = AIOHTTPTransport(url="https://gql.ivazh.ru/graphql/")
def get_classifier():
client = Client(transport=transport, fetch_schema_from_transport=True)
query = gql(
"""
query getClassifier {
getClassifier(name: "ood")
}
"""
)
result = client.execute(query)
return result['getClassifier']
def get_catalog():
client = Client(transport=transport, fetch_schema_from_transport=True)
query = gql(
"""
query getCatalog {
getCatalog(name: "ood")
}
"""
)
result = client.execute(query)
return result['getCatalog']
def get_object(oid: str):
client = Client(transport=transport, fetch_schema_from_transport=True)
query = gql(
"""
query getObjects($oid: String!) {
getObject(name: "ood", oid: $oid)
}
"""
)
params = {'oid': oid}
result = client.execute(query, variable_values=params)
return result['getObject']