Merge pull request #420 from LegNeato/async-await

Replace `futures::future::FutureExt::boxed` with `Box::pin`Rebase on master and
This commit is contained in:
theduke 2019-08-27 09:24:49 +02:00 committed by GitHub
commit 625955ab79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 24 deletions

View file

@ -181,7 +181,7 @@ pub use crate::{
pub type BoxFuture<'a, T> = std::pin::Pin<Box<dyn std::future::Future<Output = T> + 'a + Send>>;
#[cfg(feature = "async")]
pub use crate::types::async_await::{GraphQLTypeAsync};
pub use crate::types::async_await::GraphQLTypeAsync;
/// An error that prevented query execution
#[derive(Debug, PartialEq)]

View file

@ -432,7 +432,7 @@ macro_rules! graphql_scalar {
use $crate::GraphQLType;
use futures::future;
let v = self.resolve(info, selection_set, executor);
future::FutureExt::boxed(future::ready(v))
Box::pin(future::ready(v))
}
}
);

View file

@ -99,7 +99,7 @@ where
match field_name {
"__schema" | "__type" => {
let v = self.resolve_field(info, field_name, arguments, executor);
ready(v).boxed()
Box::pin(ready(v))
}
_ => self
.query_type

View file

@ -1,9 +1,12 @@
use crate::{
ast::{Directive, FromInputValue, InputValue, Selection},
value::{Object, ScalarRefValue, ScalarValue, Value},
};
use crate::ast::{Directive, FromInputValue, InputValue, Selection};
use crate::value::{Object, ScalarRefValue, ScalarValue, Value};
use crate::executor::{ExecutionResult, Executor};
use crate::parser::Spanning;
use crate::{
executor::{ExecutionResult, Executor},
parser::Spanning,
};
use crate::BoxFuture;
@ -57,9 +60,12 @@ where
'e: 'a,
for<'b> &'b S: ScalarRefValue<'b>,
{
use futures::future::FutureExt;
resolve_selection_set_into_async_recursive(instance, info, selection_set, executor).boxed()
Box::pin(resolve_selection_set_into_async_recursive(
instance,
info,
selection_set,
executor,
))
}
struct AsyncField<S> {
@ -86,10 +92,7 @@ where
CtxT: Send + Sync,
for<'b> &'b S: ScalarRefValue<'b>,
{
use futures::{
future::FutureExt,
stream::{FuturesOrdered, StreamExt},
};
use futures::stream::{FuturesOrdered, StreamExt};
let mut object = Object::with_capacity(selection_set.len());
@ -180,7 +183,7 @@ where
value,
})
};
async_values.push(field_future.boxed());
async_values.push(Box::pin(field_future));
}
Selection::FragmentSpread(Spanning {
item: ref spread, ..
@ -203,7 +206,7 @@ where
.await;
AsyncValue::Nested(value)
};
async_values.push(f.boxed());
async_values.push(Box::pin(f));
}
Selection::InlineFragment(Spanning {
item: ref fragment,
@ -247,7 +250,7 @@ where
.await;
AsyncValue::Nested(value)
};
async_values.push(f.boxed());
async_values.push(Box::pin(f));
}
}
}

View file

@ -272,7 +272,7 @@ where
executor: &'a Executor<Self::Context, S>,
) -> crate::BoxFuture<'a, Value<S>> {
let f = resolve_into_list_async(executor, info, self.iter());
futures::future::FutureExt::boxed(f)
Box::pin(f)
}
}
@ -292,7 +292,7 @@ where
executor: &'a Executor<Self::Context, S>,
) -> crate::BoxFuture<'a, Value<S>> {
let f = resolve_into_list_async(executor, info, self.iter());
futures::future::FutureExt::boxed(f)
Box::pin(f)
}
}
@ -317,6 +317,6 @@ where
None => Value::null(),
}
};
futures::future::FutureExt::boxed(f)
Box::pin(f)
}
}

View file

@ -42,14 +42,14 @@ Check the LICENSE file for details.
use std::{
error::Error,
io::Cursor,
io::{Cursor, Read},
};
use rocket::{
data::{FromDataFuture, FromDataSimple},
data::{FromDataSimple, Outcome as FromDataOutcome},
http::{ContentType, RawStr, Status},
request::{FormItems, FromForm, FromFormValue},
response::{content, Responder, Response, ResultFuture},
response::{content, Responder, Response},
Data,
Outcome::{Failure, Forward, Success},
Request,