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:
commit
625955ab79
6 changed files with 27 additions and 24 deletions
|
@ -181,7 +181,7 @@ pub use crate::{
|
||||||
pub type BoxFuture<'a, T> = std::pin::Pin<Box<dyn std::future::Future<Output = T> + 'a + Send>>;
|
pub type BoxFuture<'a, T> = std::pin::Pin<Box<dyn std::future::Future<Output = T> + 'a + Send>>;
|
||||||
|
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
pub use crate::types::async_await::{GraphQLTypeAsync};
|
pub use crate::types::async_await::GraphQLTypeAsync;
|
||||||
|
|
||||||
/// An error that prevented query execution
|
/// An error that prevented query execution
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
|
|
@ -432,7 +432,7 @@ macro_rules! graphql_scalar {
|
||||||
use $crate::GraphQLType;
|
use $crate::GraphQLType;
|
||||||
use futures::future;
|
use futures::future;
|
||||||
let v = self.resolve(info, selection_set, executor);
|
let v = self.resolve(info, selection_set, executor);
|
||||||
future::FutureExt::boxed(future::ready(v))
|
Box::pin(future::ready(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -99,7 +99,7 @@ where
|
||||||
match field_name {
|
match field_name {
|
||||||
"__schema" | "__type" => {
|
"__schema" | "__type" => {
|
||||||
let v = self.resolve_field(info, field_name, arguments, executor);
|
let v = self.resolve_field(info, field_name, arguments, executor);
|
||||||
ready(v).boxed()
|
Box::pin(ready(v))
|
||||||
}
|
}
|
||||||
_ => self
|
_ => self
|
||||||
.query_type
|
.query_type
|
||||||
|
|
|
@ -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::{
|
||||||
use crate::value::{Object, ScalarRefValue, ScalarValue, Value};
|
executor::{ExecutionResult, Executor},
|
||||||
|
parser::Spanning,
|
||||||
use crate::executor::{ExecutionResult, Executor};
|
};
|
||||||
use crate::parser::Spanning;
|
|
||||||
|
|
||||||
use crate::BoxFuture;
|
use crate::BoxFuture;
|
||||||
|
|
||||||
|
@ -57,9 +60,12 @@ where
|
||||||
'e: 'a,
|
'e: 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
for<'b> &'b S: ScalarRefValue<'b>,
|
||||||
{
|
{
|
||||||
use futures::future::FutureExt;
|
Box::pin(resolve_selection_set_into_async_recursive(
|
||||||
|
instance,
|
||||||
resolve_selection_set_into_async_recursive(instance, info, selection_set, executor).boxed()
|
info,
|
||||||
|
selection_set,
|
||||||
|
executor,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AsyncField<S> {
|
struct AsyncField<S> {
|
||||||
|
@ -86,10 +92,7 @@ where
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
for<'b> &'b S: ScalarRefValue<'b>,
|
||||||
{
|
{
|
||||||
use futures::{
|
use futures::stream::{FuturesOrdered, StreamExt};
|
||||||
future::FutureExt,
|
|
||||||
stream::{FuturesOrdered, StreamExt},
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut object = Object::with_capacity(selection_set.len());
|
let mut object = Object::with_capacity(selection_set.len());
|
||||||
|
|
||||||
|
@ -180,7 +183,7 @@ where
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
async_values.push(field_future.boxed());
|
async_values.push(Box::pin(field_future));
|
||||||
}
|
}
|
||||||
Selection::FragmentSpread(Spanning {
|
Selection::FragmentSpread(Spanning {
|
||||||
item: ref spread, ..
|
item: ref spread, ..
|
||||||
|
@ -203,7 +206,7 @@ where
|
||||||
.await;
|
.await;
|
||||||
AsyncValue::Nested(value)
|
AsyncValue::Nested(value)
|
||||||
};
|
};
|
||||||
async_values.push(f.boxed());
|
async_values.push(Box::pin(f));
|
||||||
}
|
}
|
||||||
Selection::InlineFragment(Spanning {
|
Selection::InlineFragment(Spanning {
|
||||||
item: ref fragment,
|
item: ref fragment,
|
||||||
|
@ -247,7 +250,7 @@ where
|
||||||
.await;
|
.await;
|
||||||
AsyncValue::Nested(value)
|
AsyncValue::Nested(value)
|
||||||
};
|
};
|
||||||
async_values.push(f.boxed());
|
async_values.push(Box::pin(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ where
|
||||||
executor: &'a Executor<Self::Context, S>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> crate::BoxFuture<'a, Value<S>> {
|
) -> crate::BoxFuture<'a, Value<S>> {
|
||||||
let f = resolve_into_list_async(executor, info, self.iter());
|
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>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> crate::BoxFuture<'a, Value<S>> {
|
) -> crate::BoxFuture<'a, Value<S>> {
|
||||||
let f = resolve_into_list_async(executor, info, self.iter());
|
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(),
|
None => Value::null(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
futures::future::FutureExt::boxed(f)
|
Box::pin(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,14 +42,14 @@ Check the LICENSE file for details.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
io::Cursor,
|
io::{Cursor, Read},
|
||||||
};
|
};
|
||||||
|
|
||||||
use rocket::{
|
use rocket::{
|
||||||
data::{FromDataFuture, FromDataSimple},
|
data::{FromDataSimple, Outcome as FromDataOutcome},
|
||||||
http::{ContentType, RawStr, Status},
|
http::{ContentType, RawStr, Status},
|
||||||
request::{FormItems, FromForm, FromFormValue},
|
request::{FormItems, FromForm, FromFormValue},
|
||||||
response::{content, Responder, Response, ResultFuture},
|
response::{content, Responder, Response},
|
||||||
Data,
|
Data,
|
||||||
Outcome::{Failure, Forward, Success},
|
Outcome::{Failure, Forward, Success},
|
||||||
Request,
|
Request,
|
||||||
|
|
Loading…
Reference in a new issue