graphql_schema_from_str!() { /* proc-macro */ }Expand description
Evaluates to a Schema object given a literal
Rust str containing GraphQL document text that represents a GraphQL
schema.
This macro is effectively a compile-time version of
SchemaBuilder::build_from_str().
Example usage:
use libgraphql::macros::graphql_schema_from_str;
let schema = graphql_schema_from_str!(r#"
type Query {
me: User,
}
type User {
firstName: String,
lastName: String,
}
"#r);
let user_type =
schema.defined_types()
.get("User")
.unwrap()
.as_object()
.unwrap();
assert_eq!(user_type.name(), "User");
assert_eq!(user_type.fields().get("firstName").is_some(), true);
assert_eq!(user_type.fields().get("firstName").is_some(), true);
assert_eq!(user_type.fields().get("doesntExist").is_some(), false);