graphql_tools/parser/
mod.rs

1//! Graphql Parser
2//! ==============
3//!
4//! This library contains full parser and formatter of the graphql
5//! query language as well as AST types.
6//!
7//! Example: Parse and Format Query
8//! -------------------------------
9//!
10//! ```rust
11//! # extern crate graphql_tools;
12//! use graphql_tools::parser::query::{parse_query, ParseError};
13//!
14//! # fn parse() -> Result<(), ParseError> {
15//! let ast = parse_query::<&str>("query MyQuery { field1, field2 }")?;
16//! // Format canonical representation
17//! assert_eq!(format!("{}", ast), "\
18//! query MyQuery {
19//!   field1
20//!   field2
21//! }
22//! ");
23//! # Ok(())
24//! # }
25//! # fn main() {
26//! #    parse().unwrap()
27//! # }
28//! ```
29//!
30//! Example: Parse and Format Schema
31//! --------------------------------
32//!
33//! ```rust
34//! # extern crate graphql_tools;
35//! use graphql_tools::parser::schema::{parse_schema, ParseError};
36//!
37//! # fn parse() -> Result<(), ParseError> {
38//! let ast = parse_schema::<String>(r#"
39//!     schema {
40//!         query: Query
41//!     }
42//!     type Query {
43//!         users: [User!]!,
44//!     }
45//!     """
46//!        Example user object
47//!
48//!        This is just a demo comment.
49//!     """
50//!     type User {
51//!         name: String!,
52//!     }
53//! "#)?.to_owned();
54//! // Format canonical representation
55//! assert_eq!(format!("{}", ast), "\
56//! schema {
57//!   query: Query
58//! }
59//!
60//! type Query {
61//!   users: [User!]!
62//! }
63//!
64//! \"\"\"
65//!   Example user object
66//!
67//!   This is just a demo comment.
68//! \"\"\"
69//! type User {
70//!   name: String!
71//! }
72//! ");
73//! # Ok(())
74//! # }
75//! # fn main() {
76//! #    parse().unwrap()
77//! # }
78//! ```
79//!
80
81mod common;
82#[macro_use]
83mod format;
84mod helpers;
85mod position;
86mod tokenizer;
87
88pub mod query;
89pub mod schema;
90
91pub use format::Style;
92pub use position::Pos;
93pub use query::parse_query;
94pub use query::parse_query_with_token_limit;
95pub use query::{minify_query, minify_query_document};
96pub use schema::parse_schema;