47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
from gql import gql, Client
|
|
from gql.transport.aiohttp import AIOHTTPTransport
|
|
from .config import Config
|
|
|
|
transport = AIOHTTPTransport(url=Config.gql_url)
|
|
service = Config.gql_schema
|
|
|
|
|
|
def get_classifier():
|
|
client = Client(transport=transport, fetch_schema_from_transport=True, execute_timeout=None)
|
|
query = gql(
|
|
"""
|
|
query getClassifier($name: String!) {
|
|
getClassifier(name: $name)
|
|
}
|
|
"""
|
|
)
|
|
result = client.execute(query, variable_values={"name": service}, )
|
|
return result['getClassifier']
|
|
|
|
|
|
def get_catalog():
|
|
client = Client(transport=transport, fetch_schema_from_transport=True, execute_timeout=None)
|
|
query = gql(
|
|
"""
|
|
query getCatalog($name: String!) {
|
|
getCatalog(name: $name)
|
|
}
|
|
"""
|
|
)
|
|
result = client.execute(query, variable_values={"name": service})
|
|
return result['getCatalog']
|
|
|
|
|
|
def get_object(oid: str):
|
|
client = Client(transport=transport, fetch_schema_from_transport=True, execute_timeout=None)
|
|
query = gql(
|
|
"""
|
|
query getObjects($oid: String!, $name: String!) {
|
|
getObject(name: $name, oid: $oid)
|
|
}
|
|
"""
|
|
)
|
|
params = {'oid': oid, 'name': service}
|
|
result = client.execute(query, variable_values=params)
|
|
return result['getObject']
|