1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! `libgraphql-parser` provides a lossless, error-tolerant, and
//! highly-optimized
//! [GraphQL tokenizer](crate::token::StrGraphQLTokenSource) and
//! [GraphQL parser](GraphQLParser). Capable of parsing schema documents,
//! executable documents, and mixed schema + executable documents.
//!
//! By default, `libgraphql-parser` targets the
//! [September 2025 GraphQL Spec](https://spec.graphql.org/September2025/).
//!
//! ## Usage
//!
//! ##### Parse valid documents
//!
//! ```rust
//! # use libgraphql_parser;
//! # use libgraphql_parser::GraphQLParser;
//! # use libgraphql_parser::ParseResult;
//! use libgraphql_parser::ast;
//!
//! // Parse any GraphQL document
//! let parse_result = libgraphql_parser::parse(r#"
//! type User { firstName: String, lastName: String }
//! type Query { me: User }
//!
//! query GetUserFullName {
//! me {
//! firstName,
//! lastName,
//! }
//! }
//! "#);
//! # assert!(parse_result.valid().is_some());
//!
//! // Count and print the number of top-level definitions parsed out of the
//! // GraphQL document.
//! let ast: &ast::Document<'_> = parse_result.ast();
//! println!("Parsed {} GraphQL definitions.", ast.definitions.len());
//! ```
//!
//! ##### Parse documents with errors
//!
//! ```rust
//! # use libgraphql_parser;
//! // Parse GraphQL documents with errors
//! let parse_result = libgraphql_parser::parse(r#"
//! type User { firstName String }
//! type Query { me: User }
//! "#);
//! # assert!(!parse_result.errors().is_empty(), "Expected a 'missing : token' error");
//!
//! // Access an "error recovered" version of the AST -- best-effort parsing.
//! let (recovered_ast, parse_errors, _) = parse_result.recovered().unwrap();
//! # assert_eq!(recovered_ast.definitions.len(), 1, "Expected 1 recovered definition");
//! # assert_eq!(parse_errors.len(), 1, "Expected 1 parse error");
//! // Print nicely-formatted output for all parse errors
//! eprintln!(
//! "Found {} errors while parsing:\n{}",
//! parse_errors.len(),
//! parse_result.formatted_errors(),
//! );
//!
//! println!(
//! "Found {} definitions after best-effort parse error recovery.",
//! recovered_ast.definitions.len(),
//! );
//! ```
//!
//! This crate provides a unified token-based parser infrastructure with support for multiple token
//! sources (string input, proc-macro input, etc.).
pub use ByteSpan;
pub use GraphQLErrorNote;
pub use GraphQLErrorNoteKind;
pub use GraphQLParseError;
pub use GraphQLParseErrorKind;
pub use GraphQLParser;
pub use GraphQLParserConfig;
pub use SourceSpan;
pub use GraphQLStringParsingError;
pub use GraphQLTokenStream;
pub use ParseResult;
pub use ReservedNameContext;
pub use SourceMap;
pub use SourcePosition;
pub use ValueParsingError;
/// Parses a schema document from a string.
/// Parses an executable document (operations and
/// fragments) from a string.
/// Parses a mixed document (both schema and executable
/// definitions) from a string.
;