Merge pull request #883 from alisenai/master

Update Axum integration to Axum 0.5.1
This commit is contained in:
Sunli 2022-04-08 09:33:34 +08:00 committed by GitHub
commit f1a3d6d3aa
6 changed files with 6 additions and 10 deletions

@ -1 +1 @@
Subproject commit 6a63808523f7e4995f9111a3497f06921cd3b11b
Subproject commit ef09f81f6f348eb2ba4d24ec1dc4ed84b2ed684f

View File

@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"]
async-graphql = { path = "../..", version = "3.0.37" }
async-trait = "0.1.51"
axum = { version = "0.4", features = ["ws", "headers"] }
axum = { version = "0.5.1", features = ["ws", "headers"] }
bytes = "1.0.1"
http-body = "0.4.2"
serde_json = "1.0.66"

View File

@ -106,7 +106,7 @@ where
} else {
let content_type = req
.headers()
.and_then(|headers| headers.get(http::header::CONTENT_TYPE))
.get(http::header::CONTENT_TYPE)
.and_then(|value| value.to_str().ok())
.map(ToString::to_string);
let body_stream = BodyStream::from_request(req)

View File

@ -29,7 +29,7 @@ impl<B: Send> FromRequest<B> for GraphQLProtocol {
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
req.headers()
.and_then(|headers| headers.get(http::header::SEC_WEBSOCKET_PROTOCOL))
.get(http::header::SEC_WEBSOCKET_PROTOCOL)
.and_then(|value| value.to_str().ok())
.and_then(|protocols| {
protocols

View File

@ -91,8 +91,8 @@ pub async fn receive_batch_json(body: impl AsyncRead) -> Result<BatchRequest, Pa
body.read_to_end(&mut data)
.await
.map_err(ParseRequestError::Io)?;
Ok(serde_json::from_slice::<BatchRequest>(&data)
.map_err(|e| ParseRequestError::InvalidRequest(Box::new(e)))?)
serde_json::from_slice::<BatchRequest>(&data)
.map_err(|e| ParseRequestError::InvalidRequest(Box::new(e)))
}
/// Receive a GraphQL request from a body as CBOR.

View File

@ -38,7 +38,6 @@ impl<'a> Lookahead<'a> {
self.fragments,
&field.selection_set.node,
name,
self.context,
)
}
@ -108,7 +107,6 @@ fn filter<'a>(
fragments: &'a HashMap<Name, Positioned<FragmentDefinition>>,
selection_set: &'a SelectionSet,
name: &str,
context: &'a Context<'a>,
) {
for item in &selection_set.items {
match &item.node {
@ -122,7 +120,6 @@ fn filter<'a>(
fragments,
&fragment.node.selection_set.node,
name,
context,
),
Selection::FragmentSpread(spread) => {
if let Some(fragment) = fragments.get(&spread.node.fragment_name.node) {
@ -131,7 +128,6 @@ fn filter<'a>(
fragments,
&fragment.node.selection_set.node,
name,
context,
)
}
}