Expand description
§Graphql Parser
This library contains full parser and formatter of the graphql query language as well as AST types.
§Example: Parse and Format Query
use graphql_tools::parser::query::{parse_query, ParseError};
let ast = parse_query::<&str>("query MyQuery { field1, field2 }")?;
// Format canonical representation
assert_eq!(format!("{}", ast), "\
query MyQuery {
field1
field2
}
");§Example: Parse and Format Schema
use graphql_tools::parser::schema::{parse_schema, ParseError};
let ast = parse_schema::<String>(r#"
schema {
query: Query
}
type Query {
users: [User!]!,
}
"""
Example user object
This is just a demo comment.
"""
type User {
name: String!,
}
"#)?.to_owned();
// Format canonical representation
assert_eq!(format!("{}", ast), "\
schema {
query: Query
}
type Query {
users: [User!]!
}
\"\"\"
Example user object
This is just a demo comment.
\"\"\"
type User {
name: String!
}
");Re-exports§
pub use query::parse_query;pub use query::parse_query_with_token_limit;pub use query::minify_query;pub use query::minify_query_document;pub use schema::parse_schema;