diff --git a/integration_tests/juniper_tests/src/arc_fields.rs b/integration_tests/juniper_tests/src/arc_fields.rs new file mode 100644 index 00000000..5f7799f9 --- /dev/null +++ b/integration_tests/juniper_tests/src/arc_fields.rs @@ -0,0 +1,15 @@ +use std::sync::Arc; + +struct Query; + +#[juniper::graphql_object] +impl Query { + fn ping() -> Arc { + Arc::new(false) + } +} + +#[derive(juniper::GraphQLInputObject)] +struct Ping { + expect_result: Arc, +} diff --git a/integration_tests/juniper_tests/src/lib.rs b/integration_tests/juniper_tests/src/lib.rs index 19c07da4..d4f0e94b 100644 --- a/integration_tests/juniper_tests/src/lib.rs +++ b/integration_tests/juniper_tests/src/lib.rs @@ -1,6 +1,8 @@ #[cfg(test)] mod api; #[cfg(test)] +mod arc_fields; +#[cfg(test)] mod codegen; #[cfg(test)] mod custom_scalar; diff --git a/juniper/src/types/marker.rs b/juniper/src/types/marker.rs index 4d95b761..f7207fd8 100644 --- a/juniper/src/types/marker.rs +++ b/juniper/src/types/marker.rs @@ -168,5 +168,18 @@ where { } +impl IsInputType for std::sync::Arc +where + T: IsInputType + ?Sized, + S: ScalarValue, +{ +} +impl IsOutputType for std::sync::Arc +where + T: IsOutputType + ?Sized, + S: ScalarValue, +{ +} + impl<'a, S> IsInputType for str where S: ScalarValue {} impl<'a, S> IsOutputType for str where S: ScalarValue {} diff --git a/juniper/src/types/pointers.rs b/juniper/src/types/pointers.rs index 2ed2d50a..0c3d0f7e 100644 --- a/juniper/src/types/pointers.rs +++ b/juniper/src/types/pointers.rs @@ -283,6 +283,19 @@ where } } +impl FromInputValue for Arc +where + S: ScalarValue, + T: FromInputValue, +{ + fn from_input_value(v: &InputValue) -> Option> { + match >::from_input_value(v) { + Some(v) => Some(Arc::new(v)), + None => None, + } + } +} + impl ToInputValue for Arc where S: fmt::Debug,