Skip to content

Commit 1b096f5

Browse files
authored
Merge pull request #2390 from Urgau/gh-graph-ql-response-size
Increase the default maximum response size for GraphQl queries
2 parents c62bfaa + ca0c1f1 commit 1b096f5

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/github/client.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl GithubClient {
143143
Ok(e) => {
144144
return Err(anyhow::Error::new(*e)).with_context(|| {
145145
format!(
146-
"req={req_url} (x-github-request-id: {}): lenght exceeded (over {max_response_size} bytes)",
146+
"req={req_url} (x-github-request-id: {}): max response size exceeded (over {max_response_size} bytes)",
147147
github_request_id
148148
.as_ref()
149149
.and_then(|v| v.to_str().ok())
@@ -333,11 +333,21 @@ impl GithubClient {
333333
query: &str,
334334
vars: serde_json::Value,
335335
) -> anyhow::Result<serde_json::Value> {
336-
self.json(self.post(&self.graphql_url).json(&serde_json::json!({
337-
"query": query,
338-
"variables": vars,
339-
})))
340-
.await
336+
// Our GraphQl query can end-up being quite big, let's set a higher default
337+
// response size than for normal REST Api response.
338+
const MAX_DEFAULT_GRAPH_QL_RESPONSE_SIZE: usize = 6 * 1024 * 1024;
339+
340+
let (body, _dbg) = self
341+
.send_req_with_limit(
342+
self.post(&self.graphql_url).json(&serde_json::json!({
343+
"query": query,
344+
"variables": vars,
345+
})),
346+
MAX_DEFAULT_GRAPH_QL_RESPONSE_SIZE,
347+
)
348+
.await?;
349+
350+
Ok(serde_json::from_slice(&body)?)
341351
}
342352

343353
/// Issues an ad-hoc GraphQL query.

0 commit comments

Comments
 (0)