From c984457e914e81f9fe6f4fcbf02c69e355be3800 Mon Sep 17 00:00:00 2001
From: Christian Legnitto <christian.legnitto@robinhood.com>
Date: Mon, 27 Jan 2020 22:52:07 -0500
Subject: [PATCH] Fix scalar and some tests under async

there is still some weirdness going on. Running async and
non-async tests in `integration_tests/*` works, but running it
from `integration_tests` does not.
---
 integration_tests/juniper_tests/src/codegen/derive_enum.rs     | 3 +++
 integration_tests/juniper_tests/src/codegen/derive_object.rs   | 3 +++
 .../juniper_tests/src/codegen/derive_object_with_raw_idents.rs | 3 +++
 integration_tests/juniper_tests/src/codegen/impl_union.rs      | 3 +++
 .../juniper_tests/src/codegen/scalar_value_transparent.rs      | 2 ++
 integration_tests/juniper_tests/src/custom_scalar.rs           | 3 +++
 integration_tests/juniper_tests/src/issue_371.rs               | 3 +++
 integration_tests/juniper_tests/src/issue_398.rs               | 3 +++
 juniper/src/macros/scalar.rs                                   | 2 --
 juniper/src/types/scalars.rs                                   | 2 ++
 10 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/integration_tests/juniper_tests/src/codegen/derive_enum.rs b/integration_tests/juniper_tests/src/codegen/derive_enum.rs
index 5dc1848e..e7528601 100644
--- a/integration_tests/juniper_tests/src/codegen/derive_enum.rs
+++ b/integration_tests/juniper_tests/src/codegen/derive_enum.rs
@@ -4,6 +4,9 @@ use fnv::FnvHashMap;
 #[cfg(test)]
 use juniper::{self, DefaultScalarValue, FromInputValue, GraphQLType, InputValue, ToInputValue};
 
+#[cfg(feature = "async")]
+use futures;
+
 #[derive(juniper::GraphQLEnum, Debug, PartialEq)]
 #[graphql(name = "Some", description = "enum descr")]
 enum SomeEnum {
diff --git a/integration_tests/juniper_tests/src/codegen/derive_object.rs b/integration_tests/juniper_tests/src/codegen/derive_object.rs
index 049eddb1..b283b542 100644
--- a/integration_tests/juniper_tests/src/codegen/derive_object.rs
+++ b/integration_tests/juniper_tests/src/codegen/derive_object.rs
@@ -7,6 +7,9 @@ use juniper::{DefaultScalarValue, GraphQLObject};
 #[cfg(test)]
 use juniper::{self, execute, EmptyMutation, GraphQLType, RootNode, Value, Variables};
 
+#[cfg(feature = "async")]
+use futures;
+
 #[derive(GraphQLObject, Debug, PartialEq)]
 #[graphql(
     name = "MyObj",
diff --git a/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs b/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs
index ddd84eaf..191967be 100644
--- a/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs
+++ b/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs
@@ -9,6 +9,9 @@ use juniper::{
     GraphQLType, RootNode, Value, Variables,
 };
 
+#[cfg(feature = "async")]
+use futures;
+
 pub struct Query;
 
 #[juniper::graphql_object]
diff --git a/integration_tests/juniper_tests/src/codegen/impl_union.rs b/integration_tests/juniper_tests/src/codegen/impl_union.rs
index 5ed28a3f..ec51097c 100644
--- a/integration_tests/juniper_tests/src/codegen/impl_union.rs
+++ b/integration_tests/juniper_tests/src/codegen/impl_union.rs
@@ -1,3 +1,6 @@
+#[cfg(feature = "async")]
+use futures;
+
 // Trait.
 
 #[derive(juniper::GraphQLObject)]
diff --git a/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs b/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs
index 6f52e5b6..244b5c5c 100644
--- a/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs
+++ b/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs
@@ -1,4 +1,6 @@
 use fnv::FnvHashMap;
+#[cfg(feature = "async")]
+use futures;
 use juniper::{DefaultScalarValue, FromInputValue, GraphQLType, InputValue, ToInputValue};
 
 #[derive(juniper::GraphQLScalarValue, PartialEq, Eq, Debug)]
diff --git a/integration_tests/juniper_tests/src/custom_scalar.rs b/integration_tests/juniper_tests/src/custom_scalar.rs
index 3fb7293e..50afc173 100644
--- a/integration_tests/juniper_tests/src/custom_scalar.rs
+++ b/integration_tests/juniper_tests/src/custom_scalar.rs
@@ -1,5 +1,8 @@
 extern crate serde_json;
 
+#[cfg(feature = "async")]
+use futures;
+
 #[cfg(test)]
 use juniper::parser::Spanning;
 #[cfg(test)]
diff --git a/integration_tests/juniper_tests/src/issue_371.rs b/integration_tests/juniper_tests/src/issue_371.rs
index d9fe27a4..749078d1 100644
--- a/integration_tests/juniper_tests/src/issue_371.rs
+++ b/integration_tests/juniper_tests/src/issue_371.rs
@@ -1,6 +1,9 @@
 // Original author of this test is <https://github.com/davidpdrsn>.
 use juniper::*;
 
+#[cfg(feature = "async")]
+use futures;
+
 pub struct Context;
 
 impl juniper::Context for Context {}
diff --git a/integration_tests/juniper_tests/src/issue_398.rs b/integration_tests/juniper_tests/src/issue_398.rs
index 7e7a71fd..b1513588 100644
--- a/integration_tests/juniper_tests/src/issue_398.rs
+++ b/integration_tests/juniper_tests/src/issue_398.rs
@@ -1,6 +1,9 @@
 // Original author of this test is <https://github.com/davidpdrsn>.
 use juniper::*;
 
+#[cfg(feature = "async")]
+use futures;
+
 struct Query;
 
 #[juniper::graphql_object]
diff --git a/juniper/src/macros/scalar.rs b/juniper/src/macros/scalar.rs
index 7f4c209d..b18f1bd4 100644
--- a/juniper/src/macros/scalar.rs
+++ b/juniper/src/macros/scalar.rs
@@ -409,8 +409,6 @@ macro_rules! graphql_scalar {
             }
         );
 
-
-        #[cfg(feature = "async")]
         $crate::__juniper_impl_trait!(
             impl <$($scalar)+> GraphQLTypeAsync for $name
                 where (
diff --git a/juniper/src/types/scalars.rs b/juniper/src/types/scalars.rs
index 8cdbea82..e4c51336 100644
--- a/juniper/src/types/scalars.rs
+++ b/juniper/src/types/scalars.rs
@@ -1,3 +1,5 @@
+#[cfg(feature = "async")]
+use futures;
 use serde_derive::{Deserialize, Serialize};
 use std::{char, convert::From, marker::PhantomData, ops::Deref, u32};