Repository: graphql-rust/juniper (language: rust)

Issue:
FieldErrors lose their extensions while being implicitly converted from user defined subscription errors
**Describe the bug**
Using question marks inside `graphql_subscription` macro causes user defined errors to be implicitly converted to `FieldError`s via `std::convert::Into` instead of `juniper::IntoFieldError`.    

Default `std::convert::From` implementation for `FieldError` populates only `FieldError::message` but not `FieldError::extensions`.

**To Reproduce**
- impl some error type which converts into `FieldError` with extensions
- define a subscription with `graphql_subscription` macro using the implemented error type
- use `?` inside the subscription body for short circuiting
- say 'goodbye' to your extensions

```rust
struct Error;

impl<S: ScalarValue> IntoFieldError<S> for Error {
    fn into_field_error(self) -> FieldError<S> {
        let mut extensions = Object::with_capacity(1);
        let _ = extensions.add_field("a",  Value::int(42));
        FieldError::new("oops", Value::Object(extensions))
    }
}

fn users_stream() -> Result<BoxStream<'static, User>, Error> {
    Err(Error)
}

#[graphql_subscription(name = "Subscription")]
impl SubscriptionsRoot {
    async fn users() -> Result<BoxStream<'static, User>, Error> {
        Ok(users_stream()?)
    }
}
```
You'll get something like:
```json
{
   "payload":{
      "errors":[
         {
            "message":"oops"
         }
      ]
   }
}
```

**Expected behavior**
Subscription returning error extensions:
```json
{
   "payload":{
      "errors":[
         {
            "message":"oops",
            "extensions": {
               "a": 42
            }
         }
      ]
   }
}
```



Discussion / hints:

Fix patch:
diff --git a/juniper_codegen/src/util/mod.rs b/juniper_codegen/src/util/mod.rs
index d007e173d..64c9caa44 100644
--- a/juniper_codegen/src/util/mod.rs
+++ b/juniper_codegen/src/util/mod.rs
@@ -1271,7 +1271,7 @@ impl GraphQLTypeDefiniton {
                 quote!(
                     #name => {
                         ::juniper::futures::FutureExt::boxed(async move {
-                            let res #_type = { #code };
+                            let res #_type = async { #code }.await;
                             let res = ::juniper::IntoFieldResult::<_, #scalar>::into_result(res)?;
                             let executor= executor.as_owned_executor();
                             let f = res.then(move |res| {


Test patch:
diff --git a/integration_tests/juniper_tests/src/issue_925.rs b/integration_tests/juniper_tests/src/issue_925.rs
new file mode 100644
index 000000000..45180262e
--- /dev/null
+++ b/integration_tests/juniper_tests/src/issue_925.rs
@@ -0,0 +1,69 @@
+use juniper::*;
+
+use futures::stream::BoxStream;
+
+#[derive(juniper::GraphQLObject)]
+struct User {
+    name: String,
+}
+
+struct Error;
+
+impl<S: ScalarValue> IntoFieldError<S> for Error {
+    fn into_field_error(self) -> FieldError<S> {
+        let a = Value::Scalar(S::from(42));
+        let mut extensions = Object::with_capacity(1);
+        let _ = extensions.add_field("a", a);
+        FieldError::new("oops", Value::Object(extensions))
+    }
+}
+
+struct SubscriptionsRoot;
+
+#[graphql_subscription(name = "Subscription")]
+impl SubscriptionsRoot {
+    async fn users() -> Result<BoxStream<'static, User>, Error> {
+        Ok(users_stream()?)
+    }
+}
+
+fn users_stream() -> Result<BoxStream<'static, User>, Error> {
+    Err(Error)
+}
+
+struct Query;
+
+#[juniper::graphql_object]
+impl Query {
+    fn users() -> Vec<User> {
+        vec![]
+    }
+}
+
+type Schema = juniper::RootNode<'static, Query, EmptyMutation<()>, SubscriptionsRoot>;
+
+#[tokio::test]
+async fn test_error_extensions() {
+    let sub = r#"
+        subscription Users {
+            users {
+                name
+            }
+        }
+    "#;
+
+    let (_, errors) = juniper::resolve_into_stream(
+        sub,
+        None,
+        &Schema::new(Query, EmptyMutation::new(), SubscriptionsRoot),
+        &Variables::new(),
+        &(),
+    )
+    .await
+    .unwrap();
+
+    assert_eq!(
+        errors.first().unwrap().error().extensions(),
+        &graphql_value!({ "a": 42 })
+    );
+}
diff --git a/integration_tests/juniper_tests/src/lib.rs b/integration_tests/juniper_tests/src/lib.rs
index a4a9c97fe..0da4dad4d 100644
--- a/integration_tests/juniper_tests/src/lib.rs
+++ b/integration_tests/juniper_tests/src/lib.rs
@@ -23,4 +23,6 @@ mod issue_914;
 #[cfg(test)]
 mod issue_922;
 #[cfg(test)]
+mod issue_925;
+#[cfg(test)]
 mod pre_parse;