Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit 4c58149

Browse files
committed
add a generic graphql query function
1 parent 07aefe9 commit 4c58149

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎src/plugins/leetcode.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ impl LeetCode {
7272
})
7373
}
7474

75+
/// Generic GraphQL query
76+
#[named]
77+
pub async fn get_graphql(&self, query: String, variables: Option<String>) -> Result<Response, Error> {
78+
let url = &self.conf.sys.urls.get("graphql").ok_or(Error::NoneError)?;
79+
let refer = self.conf.sys.urls.get("base").ok_or(Error::NoneError)?;
80+
let mut json: Json = HashMap::new();
81+
json.insert("operationName", "a".to_string());
82+
if let Some(v) = variables {
83+
json.insert("variables", v);
84+
}
85+
json.insert("query", query);
86+
87+
let mut req = make_req!(self, url.to_string());
88+
req.mode = Mode::Post(json);
89+
req.refer = Some(refer.to_string());
90+
req
91+
.send(&self.client)
92+
.await
93+
}
94+
7595
/// Get category problems
7696
#[named]
7797
pub async fn get_category_problems(&self, category: &str) -> Result<Response, Error> {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /