From e03e525645d4a038527da04f29c6a230323e5a50 Mon Sep 17 00:00:00 2001 From: nWacky Date: Fri, 1 Nov 2019 14:26:08 +0300 Subject: [PATCH] Start adding `async-trait` to `GraphQLTypeAsync` --- juniper/Cargo.toml | 7 +++---- juniper/src/types/async_await.rs | 9 +++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 5e671238..a0eb926a 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -35,18 +35,17 @@ default = [ [dependencies] 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" +futures-preview = { version = "=0.3.0-alpha.19", optional = true } indexmap = { version = "1.0.0", features = ["serde-1"] } serde = { version = "1.0.8" } serde_derive = { version = "1.0.2" } - -chrono = { version = "0.4.0", optional = true } serde_json = { version="1.0.2", optional = true } url = { version = "2", optional = true } uuid = { version = "0.7", optional = true } -futures-preview = { version = "=0.3.0-alpha.19", optional = true } - [dev-dependencies] bencher = "0.1.2" serde_json = { version = "1.0.2" } diff --git a/juniper/src/types/async_await.rs b/juniper/src/types/async_await.rs index ab7b95d4..3b7971a9 100644 --- a/juniper/src/types/async_await.rs +++ b/juniper/src/types/async_await.rs @@ -12,6 +12,7 @@ use crate::BoxFuture; use super::base::{is_excluded, merge_key_into, Arguments, GraphQLType}; +#[async_trait] pub trait GraphQLTypeAsync: GraphQLType + Send + Sync where Self::Context: Send + Sync, @@ -19,22 +20,22 @@ where S: ScalarValue + Send + Sync, for<'b> &'b S: ScalarRefValue<'b>, { - fn resolve_field_async<'a>( + async fn resolve_field_async<'a>( &'a self, info: &'a Self::TypeInfo, field_name: &'a str, arguments: &'a Arguments, executor: &'a Executor, - ) -> BoxFuture<'a, ExecutionResult> { + ) -> ExecutionResult { panic!("resolve_field must be implemented by object types"); } - fn resolve_async<'a>( + async fn resolve_async<'a>( &'a self, info: &'a Self::TypeInfo, selection_set: Option<&'a [Selection]>, executor: &'a Executor, - ) -> BoxFuture<'a, Value> { + ) -> Value { if let Some(selection_set) = selection_set { resolve_selection_set_into_async(self, info, selection_set, executor) } else {