Start adding async-trait
to GraphQLTypeAsync
This commit is contained in:
parent
bfe6c7ae97
commit
e03e525645
2 changed files with 8 additions and 8 deletions
|
@ -35,18 +35,17 @@ default = [
|
||||||
[dependencies]
|
[dependencies]
|
||||||
juniper_codegen = { version = "0.14.1", path = "../juniper_codegen" }
|
juniper_codegen = { version = "0.14.1", path = "../juniper_codegen" }
|
||||||
|
|
||||||
|
async-trait = "0.1.16"
|
||||||
|
chrono = { version = "0.4.0", optional = true }
|
||||||
fnv = "1.0.3"
|
fnv = "1.0.3"
|
||||||
|
futures-preview = { version = "=0.3.0-alpha.19", optional = true }
|
||||||
indexmap = { version = "1.0.0", features = ["serde-1"] }
|
indexmap = { version = "1.0.0", features = ["serde-1"] }
|
||||||
serde = { version = "1.0.8" }
|
serde = { version = "1.0.8" }
|
||||||
serde_derive = { version = "1.0.2" }
|
serde_derive = { version = "1.0.2" }
|
||||||
|
|
||||||
chrono = { version = "0.4.0", optional = true }
|
|
||||||
serde_json = { version="1.0.2", optional = true }
|
serde_json = { version="1.0.2", optional = true }
|
||||||
url = { version = "2", optional = true }
|
url = { version = "2", optional = true }
|
||||||
uuid = { version = "0.7", optional = true }
|
uuid = { version = "0.7", optional = true }
|
||||||
|
|
||||||
futures-preview = { version = "=0.3.0-alpha.19", optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bencher = "0.1.2"
|
bencher = "0.1.2"
|
||||||
serde_json = { version = "1.0.2" }
|
serde_json = { version = "1.0.2" }
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::BoxFuture;
|
||||||
|
|
||||||
use super::base::{is_excluded, merge_key_into, Arguments, GraphQLType};
|
use super::base::{is_excluded, merge_key_into, Arguments, GraphQLType};
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
pub trait GraphQLTypeAsync<S>: GraphQLType<S> + Send + Sync
|
pub trait GraphQLTypeAsync<S>: GraphQLType<S> + Send + Sync
|
||||||
where
|
where
|
||||||
Self::Context: Send + Sync,
|
Self::Context: Send + Sync,
|
||||||
|
@ -19,22 +20,22 @@ where
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
for<'b> &'b S: ScalarRefValue<'b>,
|
||||||
{
|
{
|
||||||
fn resolve_field_async<'a>(
|
async fn resolve_field_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
info: &'a Self::TypeInfo,
|
info: &'a Self::TypeInfo,
|
||||||
field_name: &'a str,
|
field_name: &'a str,
|
||||||
arguments: &'a Arguments<S>,
|
arguments: &'a Arguments<S>,
|
||||||
executor: &'a Executor<Self::Context, S>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> BoxFuture<'a, ExecutionResult<S>> {
|
) -> ExecutionResult<S> {
|
||||||
panic!("resolve_field must be implemented by object types");
|
panic!("resolve_field must be implemented by object types");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_async<'a>(
|
async fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
info: &'a Self::TypeInfo,
|
info: &'a Self::TypeInfo,
|
||||||
selection_set: Option<&'a [Selection<S>]>,
|
selection_set: Option<&'a [Selection<S>]>,
|
||||||
executor: &'a Executor<Self::Context, S>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> BoxFuture<'a, Value<S>> {
|
) -> Value<S> {
|
||||||
if let Some(selection_set) = selection_set {
|
if let Some(selection_set) = selection_set {
|
||||||
resolve_selection_set_into_async(self, info, selection_set, executor)
|
resolve_selection_set_into_async(self, info, selection_set, executor)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue