From 3616e36eced5a1cafff67b1f22331b017824dd1f Mon Sep 17 00:00:00 2001
From: Christian Legnitto <LegNeato@users.noreply.github.com>
Date: Tue, 14 Jul 2020 21:38:09 -1000
Subject: [PATCH] Update to latest Rocket on `master` (#699)

The `async` branch has now landed on Rocket's `master`. The git
branch has been deleted.
---
 juniper_rocket_async/Cargo.toml |  2 +-
 juniper_rocket_async/src/lib.rs | 16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/juniper_rocket_async/Cargo.toml b/juniper_rocket_async/Cargo.toml
index cc0133f3..e3d31582 100644
--- a/juniper_rocket_async/Cargo.toml
+++ b/juniper_rocket_async/Cargo.toml
@@ -15,7 +15,7 @@ edition = "2018"
 serde_json = { version = "1.0.2" }
 juniper = { version = "0.14.2", default-features = false, path = "../juniper" }
 futures = { version = "0.3.1", features = ["compat"] }
-rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "async", default-features = false }
+rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", default-features = false }
 tokio = { version = "0.2", features = ["rt-core", "macros"] }
 
 [dev-dependencies.juniper]
diff --git a/juniper_rocket_async/src/lib.rs b/juniper_rocket_async/src/lib.rs
index 41cd12d4..ac27c611 100644
--- a/juniper_rocket_async/src/lib.rs
+++ b/juniper_rocket_async/src/lib.rs
@@ -42,7 +42,7 @@ Check the LICENSE file for details.
 use std::io::Cursor;
 
 use rocket::{
-    data::{FromDataFuture, FromDataSimple},
+    data::{self, FromData},
     http::{ContentType, RawStr, Status},
     request::{FormItems, FromForm, FromFormValue},
     response::{self, content, Responder, Response},
@@ -288,13 +288,14 @@ where
 
 const BODY_LIMIT: u64 = 1024 * 100;
 
-impl<S> FromDataSimple for GraphQLRequest<S>
+#[rocket::async_trait]
+impl<S> FromData for GraphQLRequest<S>
 where
     S: ScalarValue,
 {
     type Error = String;
 
-    fn from_data(req: &Request, data: Data) -> FromDataFuture<'static, Self, Self::Error> {
+    async fn from_data(req: &Request<'_>, data: Data) -> data::Outcome<Self, Self::Error> {
         use tokio::io::AsyncReadExt as _;
 
         let content_type = req
@@ -303,7 +304,7 @@ where
         let is_json = match content_type {
             Some(("application", "json")) => true,
             Some(("application", "graphql")) => false,
-            _ => return Box::pin(async move { Forward(data) }),
+            _ => return Box::pin(async move { Forward(data) }).await,
         };
 
         Box::pin(async move {
@@ -322,6 +323,7 @@ where
                 GraphQLBatchRequest::Single(http::GraphQLRequest::new(body, None, None))
             }))
         })
+        .await
     }
 }
 
@@ -464,7 +466,7 @@ mod tests {
     use rocket::{
         self, get,
         http::ContentType,
-        local::{Client, LocalResponse},
+        local::asynchronous::{Client, LocalResponse},
         post,
         request::Form,
         routes, Rocket, State,
@@ -566,14 +568,14 @@ mod tests {
         ))
     }
 
-    async fn make_test_response(mut response: LocalResponse<'_>) -> http_tests::TestResponse {
+    async fn make_test_response(response: LocalResponse<'_>) -> http_tests::TestResponse {
         let status_code = response.status().code as i32;
         let content_type = response
             .content_type()
             .expect("No content type header from handler")
             .to_string();
         let body = response
-            .body_string()
+            .into_string()
             .await
             .expect("No body returned from GraphQL handler");