-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnetwork.py
42 lines (34 loc) · 1.48 KB
/
network.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from pygqlmap.network import GQLResponse, send_http_request
from .src.sp_builder import SchemaBuilder, SchemaTypeBuilder
from .src.sp_schema import GQLSchema, SCType
def fetch_schema_response(url, httpHeaders, query):
try:
payload = { "query": query }
response = send_http_request(url, payload, httpHeaders)
except Exception as ex:
raise ex
return GQLSchemaResponse(response)
def fetch_schema_obj(url, headers, query):
gql_response = fetch_schema_response(url, headers, query)
gql_response.map_gqldata_to_obj()
gql_response.print_msg_out()
return gql_response.result_obj
class GQLSchemaResponse(GQLResponse):
def map_gqldata_to_obj(self, mapped_py_obj = None, build_sctype = None):
"""_summary_
Args:
includeDeprecated (bool, optional): Decides if deprecated values are to be included.
Defaults to True.
Returns:
_type_: _description_
"""
if self.data:
for root_obj in self.data.keys():
if root_obj == '__schema': #check self.data type
builder = SchemaBuilder()
self.result_obj = builder.build(self.data, GQLSchema())
elif root_obj == '__type': #check self.data type
builder = SchemaTypeBuilder()
self.result_obj = builder.build(self.data, SCType())
else:
self.result_obj = None