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

Issue:
FieldResult with a unit return type panics
I have a mutation which returns a unit like this.
```rust
  field signup(&executor, params: user::SignUpParams) -> FieldResult<()> {
```
This causes this panic to happen,
```
thread '<unnamed>' panicked at 'resolve() must be implemented by non-object output types', /home/pyros2097/.cargo/registry/src/github.com-1ecc6299db9ec823/juniper-0.9.2/src/types/base.rs:320:13
stack backtrace:
```
So shouldn't resolve be automatically implemented for () type or something. Right now after the panic the response is an empty "" which I think is because of serde.



Discussion / hints:
What should unit be serialized as? An empty string? Null? I don't think it is clear
Possible duplicate of #29? However, if I recall the specs correctly there is no void type and this indicated in the linked issue as well. The common strategy from my experience is just have a successful/success/ok field within the mutation response object that returns true or false. 
Could we do a nicer error message at compile time?
I can probably take a crack at doing a compile time error for void types after finals, so May.  
Is there a reason why we don't just remove the impl for `()`?

This would be the sanest choice IMO.

Fix patch:
diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md
index f88db0455..ad38683b5 100644
--- a/juniper/CHANGELOG.md
+++ b/juniper/CHANGELOG.md
@@ -18,6 +18,7 @@ This should not have any impact on your code, since juniper already was 2018 com
 ### Other changes
 
 - The minimum required Rust version is now `1.34.0`.
+- The `GraphQLType` impl for () was removed to improve compile time safefty. [#355](https://github.com/graphql-rust/juniper/pull/355)
 - The `ScalarValue` custom derive has been renamed to `GraphQLScalarValue`.
 - Added built-in support for the canonical schema introspection query via
   `juniper::introspect()`. 
diff --git a/juniper/src/types/scalars.rs b/juniper/src/types/scalars.rs
index f62685091..6b969ce5f 100644
--- a/juniper/src/types/scalars.rs
+++ b/juniper/src/types/scalars.rs
@@ -1,15 +1,14 @@
 use std::convert::From;
-use std::fmt::Debug;
 use std::marker::PhantomData;
 use std::ops::Deref;
 use std::{char, u32};
 
-use crate::ast::{FromInputValue, InputValue, Selection, ToInputValue};
+use crate::ast::{InputValue, Selection, ToInputValue};
 use crate::executor::{Executor, Registry};
 use crate::parser::{LexerError, ParseError, ScalarToken, Token};
 use crate::schema::meta::MetaType;
 use crate::types::base::GraphQLType;
-use crate::value::{ParseScalarResult, ParseScalarValue, ScalarRefValue, ScalarValue, Value};
+use crate::value::{ParseScalarResult, ScalarRefValue, ScalarValue, Value};
 
 /// An ID as defined by the GraphQL specification
 ///
@@ -274,46 +273,7 @@ graphql_scalar!(f64 as "Float" where Scalar = <S>{
     }
 });
 
-impl<S> GraphQLType<S> for ()
-where
-    S: ScalarValue,
-    for<'b> &'b S: ScalarRefValue<'b>,
-{
-    type Context = ();
-    type TypeInfo = ();
-
-    fn name(_: &()) -> Option<&str> {
-        Some("__Unit")
-    }
-
-    fn meta<'r>(_: &(), registry: &mut Registry<'r, S>) -> MetaType<'r, S>
-    where
-        S: 'r,
-        for<'b> &'b S: ScalarRefValue<'b>,
-    {
-        registry.build_scalar_type::<Self>(&()).into_meta()
-    }
-}
-
-impl<S> ParseScalarValue<S> for ()
-where
-    S: ScalarValue,
-{
-    fn from_str<'a>(_value: ScalarToken<'a>) -> ParseScalarResult<'a, S> {
-        Ok(S::from(0))
-    }
-}
-
-impl<S: Debug> FromInputValue<S> for () {
-    fn from_input_value<'a>(_: &'a InputValue<S>) -> Option<()>
-    where
-        for<'b> &'b S: ScalarRefValue<'b>,
-    {
-        None
-    }
-}
-
-/// Utility type to define read-only schemas
+/// Utillity type to define read-only schemas
 ///
 /// If you instantiate `RootNode` with this as the mutation, no mutation will be
 /// generated for the schema.


Test patch: