use crate::{registry, ContextSelectionSet, GQLInputValue, GQLOutputValue, GQLType, Result, Value}; use std::borrow::Cow; impl GQLType for Option { fn type_name() -> Cow<'static, str> { T::type_name() } fn qualified_type_name() -> String { T::type_name().to_string() } fn create_type_info(registry: &mut registry::Registry) -> String { T::create_type_info(registry) } } impl GQLInputValue for Option { fn parse(value: Value) -> Option { match value { Value::Null => Some(None), _ => Some(GQLInputValue::parse(value)?), } } fn parse_from_json(value: serde_json::Value) -> Option { match value { serde_json::Value::Null => Some(None), _ => Some(GQLInputValue::parse_from_json(value)?), } } } #[async_trait::async_trait] impl GQLOutputValue for Option { async fn resolve(&self, ctx: &ContextSelectionSet<'_>) -> Result where { if let Some(inner) = self { inner.resolve(ctx).await } else { Ok(serde_json::Value::Null) } } }