Skip to content

apollo-parser@0.2.5

Choose a tag to compare

@lrlna lrlna released this 01 Apr 10:40
· 774 commits to main since this release
4efdc6b

0.2.5 - 2021-04-01

Important: 1 breaking change below, indicated by BREAKING

BREAKING

  • GraphQL Int Values are cast to i32 - bnjjj, pull/197
    AST's Int Values have an Into implementation to their Rust type. They were
    previously converted to i64, which is not compliant with the spec. Int Values
    are now converted to i32.
    if let ast::Value::IntValue(val) =
        argument.value().expect("Cannot get argument value.")
    {
        let i: i32 = val.into();
    }

Features

  • Adds a .text() method to ast::DirectiveLocation - bnjjj, pull/197
    DirectiveLocation can now additionally be accessed with a .text() method.

    let schema = r#"directive @example on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT"#;
    let parser = Parser::new(schema);
    let ast = parser.parse();
    
    assert!(ast.errors.is_empty());
    
    let document = ast.document();
    for definition in document.definitions() {
        if let ast::Definition::DirectiveDefinition(dir_def) = definition {
            let dir_locations: Vec<String> = dir_def
                .directive_locations()
                .unwrap()
                .directive_locations()
                .map(|loc| loc.text().unwrap().to_string())
                .collect();
            assert_eq!(
                dir_locations,
                ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"]
            );
            return;
        }
    }