From 1cb305cc1a0e91dc866ccc24faef53b49b5fbbde Mon Sep 17 00:00:00 2001 From: tyranron Date: Tue, 29 Mar 2022 13:26:58 +0300 Subject: [PATCH] Backport making request body size `Limit` configurable in `juniper_rocket` (#1044) Co-authored-by: Filip Gospodinov --- juniper_rocket/CHANGELOG.md | 6 +++++- juniper_rocket/Cargo.toml | 2 +- juniper_rocket/src/lib.rs | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/juniper_rocket/CHANGELOG.md b/juniper_rocket/CHANGELOG.md index 7f0e099d..064bca28 100644 --- a/juniper_rocket/CHANGELOG.md +++ b/juniper_rocket/CHANGELOG.md @@ -2,7 +2,11 @@ - Compatibility with the latest `juniper`. -# [[0.8.0] 2021-07-08](https://github.com/graphql-rust/juniper/releases/tag/juniper_rocket-0.8.0) +# [[0.8.1] 2022-03-29](https://github.com/graphql-rust/juniper/releases/tag/juniper_rocket-v0.8.1) + +- Ability to set custom request body size limit ([#1044](https://github.com/graphql-rust/juniper/pull/1044)). + +# [[0.8.0] 2021-07-08](https://github.com/graphql-rust/juniper/releases/tag/juniper_rocket-v0.8.0) - Require async rocket support (`rocket` >= 0.5-rc1). - Compatibility with the latest `juniper`. diff --git a/juniper_rocket/Cargo.toml b/juniper_rocket/Cargo.toml index a518356d..d330b51d 100644 --- a/juniper_rocket/Cargo.toml +++ b/juniper_rocket/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "juniper_rocket" -version = "0.8.0" +version = "0.8.1" edition = "2018" authors = [ "Magnus Hallin ", diff --git a/juniper_rocket/src/lib.rs b/juniper_rocket/src/lib.rs index 2ab7898d..71b52ebe 100644 --- a/juniper_rocket/src/lib.rs +++ b/juniper_rocket/src/lib.rs @@ -337,8 +337,9 @@ where }; Box::pin(async move { + let limit = req.limits().get("graphql").unwrap_or(BODY_LIMIT.bytes()); + let mut reader = data.open(limit); let mut body = String::new(); - let mut reader = data.open(BODY_LIMIT.bytes()); if let Err(e) = reader.read_to_string(&mut body).await { return Failure((Status::InternalServerError, format!("{:?}", e))); }