pub enum GraphQLParseErrorKind {
InvalidEmptyConstruct {
construct: String,
},
InvalidSyntax,
InvalidValue(ValueParsingError),
LexerError,
MismatchedDelimiter {
expected: String,
found: String,
},
ReservedName {
name: String,
context: ReservedNameContext,
},
UnclosedDelimiter {
delimiter: String,
},
UnexpectedEof {
expected: Vec<String>,
},
UnexpectedToken {
expected: Vec<String>,
found: String,
},
UnsupportedFeature {
feature: String,
},
WrongDocumentKind {
found: DefinitionKind,
document_kind: DocumentKind,
},
}Expand description
Categorizes parse errors for programmatic handling.
Each variant contains minimal data needed for programmatic decisions.
Human-readable context (suggestions, explanations) belongs in the
notes field of GraphQLParseError.
The #[error(...)] messages are concise/programmatic. Full human-readable
messages are in GraphQLParseError.message.
Variants§
InvalidEmptyConstruct
Empty construct that requires content.
Certain constructs cannot be empty per the GraphQL spec:
- Selection sets:
{ }is invalid (must have at least one selection) - Argument lists:
()is invalid (omit parentheses if no arguments)
§Example
query { user { } }
^^^ selection set cannot be emptyInvalidSyntax
Invalid syntax that doesn’t fit other categories.
A catch-all for syntax errors without dedicated variants. The specific
error is described in GraphQLParseError.message.
InvalidValue(ValueParsingError)
Invalid value (wraps value parsing errors).
Occurs when a literal value (string, int, float) cannot be parsed.
§Example
query { field(limit: 99999999999999999999) }
^^^^^^^^^^^^^^^^^^^^ integer overflowLexerError
Lexer error encountered during parsing.
The parser encountered a GraphQLTokenKind::Error token from the lexer.
The lexer’s error message and notes are preserved in the parent
GraphQLParseError’s message and notes fields.
§Example
type User { name: "unterminated string
^ unterminated string literalMismatchedDelimiter
Mismatched delimiter.
A closing delimiter was found that doesn’t match the most recently opened delimiter. This indicates a structural nesting error.
§Example
type User { name: [String) }
^ expected `]`, found `)`Note: This is distinct from UnclosedDelimiter, which occurs when EOF
is reached without any closing delimiter.
Fields
ReservedName
Reserved name used in a context where it’s not allowed.
Certain names have special meaning in specific contexts:
oncannot be a fragment name (it introduces type conditions)true,false,nullcannot be enum values (ambiguous with literals)
§Example
fragment on on User { name }
^^ fragment name cannot be `on`Fields
context: ReservedNameContextThe context where this name is not allowed.
UnclosedDelimiter
Unclosed delimiter (bracket, brace, or parenthesis).
A delimiter was opened but EOF was reached before finding the matching
closing delimiter. The opening location is typically included in the
error’s notes.
§Example
type User {
name: String
# EOF here — missing `}`Note: This is distinct from MismatchedDelimiter, which occurs when a
wrong closing delimiter is found (e.g., [ closed with )).
UnexpectedEof
Unexpected end of input while parsing.
The document ended before a complete construct was parsed.
§Example
type User {
^ expected `}`, found end of inputUnexpectedToken
Expected specific token(s) but found something else.
This is the most common error type — the parser expected certain tokens based on grammar rules but encountered something unexpected.
§Example
type User { name String }
^^^^^^ expected `:`, found `String`Fields
UnsupportedFeature
Feature not representable in the target format.
Emitted by compatibility conversion functions when
the source AST contains features that the target
format cannot represent (e.g., variable directives
and schema extensions when converting to
graphql_parser v0.4). May also apply to future
spec-version-gated features.
WrongDocumentKind
Definition kind not allowed in the document being parsed.
When parsing with parse_executable_document(), schema definitions
(types, directives) are not allowed. When parsing with
parse_schema_document(), operations and fragments are not allowed.
§Example
# Parsing as executable document:
type User { name: String }
^^^^ type definition not allowed in executable documentFields
found: DefinitionKindWhat kind of definition was found.
document_kind: DocumentKindWhat kind of document is being parsed.
Trait Implementations§
Source§impl Clone for GraphQLParseErrorKind
impl Clone for GraphQLParseErrorKind
Source§fn clone(&self) -> GraphQLParseErrorKind
fn clone(&self) -> GraphQLParseErrorKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphQLParseErrorKind
impl Debug for GraphQLParseErrorKind
Source§impl Display for GraphQLParseErrorKind
impl Display for GraphQLParseErrorKind
Source§impl Error for GraphQLParseErrorKind
impl Error for GraphQLParseErrorKind
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()