graphql-composition 0.12.2

An implementation of GraphQL federated schema composition
Documentation
use cynic_parser_deser::ValueDeserialize;

#[derive(ValueDeserialize)]
pub struct DeprecatedDirective<'a> {
    pub reason: Option<&'a str>,
}

#[cfg(test)]
mod tests {
    use super::{super::*, *};

    #[test]
    fn test_parsing_no_reason() {
        let doc = directive_test_document("@deprecated");
        let value = parse_from_test_document::<DeprecatedDirective<'_>>(&doc).unwrap();

        assert_eq!(value.reason, None);
    }

    #[test]
    fn test_parsing_with_reason() {
        let doc = directive_test_document("@deprecated(reason: \"because I wanted to\")");
        let value = parse_from_test_document::<DeprecatedDirective<'_>>(&doc).unwrap();

        assert_eq!(value.reason, Some("because I wanted to"));
    }
}