Skip to content

Commit

Permalink
Upgrade rocket crate to 0.5.0-rc.4 version (#1205)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kai Ren <tyranron@gmail.com>
  • Loading branch information
dependabot[bot] and tyranron authored Nov 3, 2023
1 parent d0f50e7 commit ba59c95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions juniper_rocket/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ All user visible changes to `juniper_rocket` crate will be documented in this fi
### BC Breaks

- Switched to 0.16 version of [`juniper` crate].
- Switched to 0.5.0-rc.4 version of [`rocket` crate]. ([#1205])

### Added

- `AsRef` and `AsMut` implementation for `GraphQLRequest` to its inner type. ([#968], [#930])

[#930]: /../../issues/930
[#968]: /../../pull/968
[#1205]: /../../pull/1205



Expand Down
2 changes: 1 addition & 1 deletion juniper_rocket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exclude = ["/examples/", "/tests/", "/release.toml"]
[dependencies]
futures = "0.3.22"
juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false }
rocket = { version = "=0.5.0-rc.3", default-features = false }
rocket = { version = "=0.5.0-rc.4", default-features = false }
serde_json = "1.0.18"

# Fixes for `minimal-versions` check.
Expand Down
10 changes: 5 additions & 5 deletions juniper_rocket/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rocket::{
data::{self, FromData, ToByteUnit},
form::{error::ErrorKind, DataField, Error, Errors, FromForm, Options, ValueField},
http::{ContentType, Status},
outcome::Outcome::{Failure, Forward, Success},
outcome::Outcome,
response::{self, content, Responder, Response},
Data, Request,
};
Expand Down Expand Up @@ -307,7 +307,7 @@ where
let is_json = match content_type {
Some(("application", "json")) => true,
Some(("application", "graphql")) => false,
_ => return Box::pin(async move { Forward(data) }).await,
_ => return Outcome::Forward((data, Status::UnsupportedMediaType)),
};

Box::pin(async move {
Expand All @@ -318,13 +318,13 @@ where
let mut reader = data.open(limit);
let mut body = String::new();
if let Err(e) = reader.read_to_string(&mut body).await {
return Failure((Status::InternalServerError, format!("{e:?}")));
return Outcome::Error((Status::InternalServerError, format!("{e:?}")));
}

Success(GraphQLRequest(if is_json {
Outcome::Success(GraphQLRequest(if is_json {
match serde_json::from_str(&body) {
Ok(req) => req,
Err(e) => return Failure((Status::BadRequest, e.to_string())),
Err(e) => return Outcome::Error((Status::BadRequest, e.to_string())),
}
} else {
GraphQLBatchRequest::Single(http::GraphQLRequest::new(body, None, None))
Expand Down

0 comments on commit ba59c95

Please sign in to comment.