Properly namespace GraphQL utility functions
This commit is contained in:
@@ -10,7 +10,8 @@ from mimetypes import guess_type
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from ._util import *
|
from ._util import *
|
||||||
from .models import *
|
from .models import *
|
||||||
from ._graphql import graphql_queries_to_json, graphql_response_to_json, GraphQL
|
from . import _graphql
|
||||||
|
from ._graphql import GraphQL
|
||||||
from ._state import State
|
from ._state import State
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
@@ -134,7 +135,7 @@ class Client(object):
|
|||||||
try:
|
try:
|
||||||
if as_graphql:
|
if as_graphql:
|
||||||
content = check_request(r, as_json=False)
|
content = check_request(r, as_json=False)
|
||||||
return graphql_response_to_json(content)
|
return _graphql.response_to_json(content)
|
||||||
else:
|
else:
|
||||||
return check_request(r)
|
return check_request(r)
|
||||||
except FBchatFacebookError as e:
|
except FBchatFacebookError as e:
|
||||||
@@ -167,7 +168,7 @@ class Client(object):
|
|||||||
data = {
|
data = {
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"response_format": "json",
|
"response_format": "json",
|
||||||
"queries": graphql_queries_to_json(*queries),
|
"queries": _graphql.queries_to_json(*queries),
|
||||||
}
|
}
|
||||||
return tuple(self._post("/api/graphqlbatch/", data, as_graphql=True))
|
return tuple(self._post("/api/graphqlbatch/", data, as_graphql=True))
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ class ConcatJSONDecoder(json.JSONDecoder):
|
|||||||
# End shameless copy
|
# End shameless copy
|
||||||
|
|
||||||
|
|
||||||
def graphql_queries_to_json(*queries):
|
def queries_to_json(*queries):
|
||||||
"""
|
"""
|
||||||
Queries should be a list of GraphQL objects
|
Queries should be a list of GraphQL objects
|
||||||
"""
|
"""
|
||||||
@@ -37,7 +37,7 @@ def graphql_queries_to_json(*queries):
|
|||||||
return json.dumps(rtn)
|
return json.dumps(rtn)
|
||||||
|
|
||||||
|
|
||||||
def graphql_response_to_json(content):
|
def response_to_json(content):
|
||||||
content = _util.strip_json_cruft(content) # Usually only needed in some error cases
|
content = _util.strip_json_cruft(content) # Usually only needed in some error cases
|
||||||
try:
|
try:
|
||||||
j = json.loads(content, cls=ConcatJSONDecoder)
|
j = json.loads(content, cls=ConcatJSONDecoder)
|
||||||
|
Reference in New Issue
Block a user