.
This commit is contained in:
46
query_itv/reqs_graphql.py
Normal file
46
query_itv/reqs_graphql.py
Normal file
@@ -0,0 +1,46 @@
|
||||
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']
|
||||
Reference in New Issue
Block a user