graphql_query/ast/mod.rs
1//! # GraphQL Query Language AST
2//!
3//! The `graphql_query::ast` module contains the GraphQL query language AST and traits to parse and
4//! print the AST. The AST implemented in this crate is specialized to only implement the
5//! client-side GraphQL query language that clients use to make requests to a GraphQL service.
6//! [Reference](https://spec.graphql.org/October2021/#sec-Language)
7//!
8//! It's easiest to use this module by importing all of it, however, its three main parts are:
9//! - [`ASTContext`], a context containing an arena that defines the lifetime for an AST
10//! - [`ParseNode`], a trait using which AST Nodes are parsed from source text
11//! - [`PrintNode`], a trait using which AST Nodes are printed into source text
12//!
13//! The following workflow describes the minimum that's done using this module and while an AST
14//! Context is active in the given scope.
15//!
16//! ```
17//! use graphql_query::ast::*;
18//!
19//! // Create an AST Context for a document
20//! let ctx = ASTContext::new();
21//!
22//! // Parse a source text into a Document AST root node
23//! let ast = Document::parse(&ctx, "{ field }").unwrap();
24//!
25//! // Print the Document node to an output String
26//! let output = ast.print();
27//! ```
28
29#[allow(clippy::module_inception)]
30mod ast;
31
32mod ast_conversion;
33mod ast_kind;
34mod ast_util;
35mod lexer;
36mod parser;
37mod printer;
38
39pub use ast::*;
40pub use ast_kind::ASTKind;
41pub use parser::ParseNode;
42pub use printer::PrintNode;