8 releases
0.4.1 | Dec 3, 2024 |
---|---|
0.4.0 | Nov 25, 2021 |
0.3.0 | Mar 19, 2020 |
0.2.3 | Jun 28, 2019 |
0.1.0 | Feb 5, 2018 |
#69 in Parser implementations
956,948 downloads per month
Used in 193 crates
(35 directly)
130KB
4K
SLoC
Graphql Parser
This library contains full parser and formatter of the graphql query language as well as AST types.
Current this library supports full graphql syntax, and the following extensions:
- Subscriptions
- Block (triple quoted) strings
- Schema definition language a/k/a IDL (which is still in RFC)
Example: Parse and Format Query
use graphql_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_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!
}
");
GraphQL Parser
Documentation | Github | Crate
A parser, formatter and AST for graphql query and schema definition language for rust.
Supported extensions:
- Subscriptions
- Block (triple quoted) strings
License
Licensed under either of
- Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~0.8–1.3MB
~29K SLoC