Move GraphQL constants into the module
This commit is contained in:
@@ -436,7 +436,7 @@ class Client(object):
|
||||
:raises: FBchatException if request failed
|
||||
"""
|
||||
params = {"search": name, "limit": limit}
|
||||
j = self.graphql_request(GraphQL(query=GraphQL.SEARCH_USER, params=params))
|
||||
j = self.graphql_request(GraphQL(query=_graphql.SEARCH_USER, params=params))
|
||||
|
||||
return [User._from_graphql(node) for node in j[name]["users"]["nodes"]]
|
||||
|
||||
@@ -450,7 +450,7 @@ class Client(object):
|
||||
:raises: FBchatException if request failed
|
||||
"""
|
||||
params = {"search": name, "limit": limit}
|
||||
j = self.graphql_request(GraphQL(query=GraphQL.SEARCH_PAGE, params=params))
|
||||
j = self.graphql_request(GraphQL(query=_graphql.SEARCH_PAGE, params=params))
|
||||
|
||||
return [Page._from_graphql(node) for node in j[name]["pages"]["nodes"]]
|
||||
|
||||
@@ -465,7 +465,7 @@ class Client(object):
|
||||
:raises: FBchatException if request failed
|
||||
"""
|
||||
params = {"search": name, "limit": limit}
|
||||
j = self.graphql_request(GraphQL(query=GraphQL.SEARCH_GROUP, params=params))
|
||||
j = self.graphql_request(GraphQL(query=_graphql.SEARCH_GROUP, params=params))
|
||||
|
||||
return [Group._from_graphql(node) for node in j["viewer"]["groups"]["nodes"]]
|
||||
|
||||
@@ -480,7 +480,7 @@ class Client(object):
|
||||
:raises: FBchatException if request failed
|
||||
"""
|
||||
params = {"search": name, "limit": limit}
|
||||
j = self.graphql_request(GraphQL(query=GraphQL.SEARCH_THREAD, params=params))
|
||||
j = self.graphql_request(GraphQL(query=_graphql.SEARCH_THREAD, params=params))
|
||||
|
||||
rtn = []
|
||||
for node in j[name]["threads"]["nodes"]:
|
||||
|
@@ -73,8 +73,9 @@ class GraphQL(object):
|
||||
else:
|
||||
raise FBchatUserError("A query or doc_id must be specified")
|
||||
|
||||
FRAGMENT_USER = """
|
||||
QueryFragment User: User {
|
||||
|
||||
FRAGMENT_USER = """
|
||||
QueryFragment User: User {
|
||||
id,
|
||||
name,
|
||||
first_name,
|
||||
@@ -86,11 +87,11 @@ class GraphQL(object):
|
||||
url,
|
||||
gender,
|
||||
viewer_affinity
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
|
||||
FRAGMENT_GROUP = """
|
||||
QueryFragment Group: MessageThread {
|
||||
FRAGMENT_GROUP = """
|
||||
QueryFragment Group: MessageThread {
|
||||
name,
|
||||
thread_key {
|
||||
thread_fbid
|
||||
@@ -148,11 +149,11 @@ class GraphQL(object):
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
|
||||
FRAGMENT_PAGE = """
|
||||
QueryFragment Page: Page {
|
||||
FRAGMENT_PAGE = """
|
||||
QueryFragment Page: Page {
|
||||
id,
|
||||
name,
|
||||
profile_picture.width(32).height(32) {
|
||||
@@ -163,12 +164,12 @@ class GraphQL(object):
|
||||
city {
|
||||
name
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
|
||||
SEARCH_USER = (
|
||||
SEARCH_USER = (
|
||||
"""
|
||||
Query SearchUser(<search> = '', <limit> = 10) {
|
||||
Query SearchUser(<search> = '', <limit> = 10) {
|
||||
entities_named(<search>) {
|
||||
search_results.of_type(user).first(<limit>) as users {
|
||||
nodes {
|
||||
@@ -176,14 +177,14 @@ class GraphQL(object):
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
+ FRAGMENT_USER
|
||||
)
|
||||
)
|
||||
|
||||
SEARCH_GROUP = (
|
||||
SEARCH_GROUP = (
|
||||
"""
|
||||
Query SearchGroup(<search> = '', <limit> = 10, <pic_size> = 32) {
|
||||
Query SearchGroup(<search> = '', <limit> = 10, <pic_size> = 32) {
|
||||
viewer() {
|
||||
message_threads.with_thread_name(<search>).last(<limit>) as groups {
|
||||
nodes {
|
||||
@@ -191,14 +192,14 @@ class GraphQL(object):
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
+ FRAGMENT_GROUP
|
||||
)
|
||||
)
|
||||
|
||||
SEARCH_PAGE = (
|
||||
SEARCH_PAGE = (
|
||||
"""
|
||||
Query SearchPage(<search> = '', <limit> = 10) {
|
||||
Query SearchPage(<search> = '', <limit> = 10) {
|
||||
entities_named(<search>) {
|
||||
search_results.of_type(page).first(<limit>) as pages {
|
||||
nodes {
|
||||
@@ -206,14 +207,14 @@ class GraphQL(object):
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
+ FRAGMENT_PAGE
|
||||
)
|
||||
)
|
||||
|
||||
SEARCH_THREAD = (
|
||||
SEARCH_THREAD = (
|
||||
"""
|
||||
Query SearchThread(<search> = '', <limit> = 10) {
|
||||
Query SearchThread(<search> = '', <limit> = 10) {
|
||||
entities_named(<search>) {
|
||||
search_results.first(<limit>) as threads {
|
||||
nodes {
|
||||
@@ -224,9 +225,9 @@ class GraphQL(object):
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
+ FRAGMENT_USER
|
||||
+ FRAGMENT_GROUP
|
||||
+ FRAGMENT_PAGE
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user