mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-17 06:19:41 +02:00
Support GET GraphQL queries
https://feedback.yaak.app/p/support-get-graphql-queries-out-of-the-box
This commit is contained in:
@@ -268,15 +268,22 @@ pub async fn send_http_request<R: Runtime>(
|
|||||||
if body_type == "graphql" {
|
if body_type == "graphql" {
|
||||||
let query = get_str_h(&request_body, "query");
|
let query = get_str_h(&request_body, "query");
|
||||||
let variables = get_str_h(&request_body, "variables");
|
let variables = get_str_h(&request_body, "variables");
|
||||||
let body = if variables.trim().is_empty() {
|
if request.method.to_lowercase() == "get" {
|
||||||
format!(r#"{{"query":{}}}"#, serde_json::to_string(query).unwrap_or_default())
|
request_builder = request_builder.query(&[("query", query)]);
|
||||||
|
if !variables.trim().is_empty() {
|
||||||
|
request_builder = request_builder.query(&[("variables", variables)]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
format!(
|
let body = if variables.trim().is_empty() {
|
||||||
r#"{{"query":{},"variables":{variables}}}"#,
|
format!(r#"{{"query":{}}}"#, serde_json::to_string(query).unwrap_or_default())
|
||||||
serde_json::to_string(query).unwrap_or_default()
|
} else {
|
||||||
)
|
format!(
|
||||||
};
|
r#"{{"query":{},"variables":{variables}}}"#,
|
||||||
request_builder = request_builder.body(body.to_owned());
|
serde_json::to_string(query).unwrap_or_default()
|
||||||
|
)
|
||||||
|
};
|
||||||
|
request_builder = request_builder.body(body.to_owned());
|
||||||
|
}
|
||||||
} else if body_type == "application/x-www-form-urlencoded"
|
} else if body_type == "application/x-www-form-urlencoded"
|
||||||
&& request_body.contains_key("form")
|
&& request_body.contains_key("form")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user