pub enum GraphQLParseErrorKind {
UnexpectedToken {
expected: Vec<String>,
found: String,
},
UnexpectedEof {
expected: Vec<String>,
},
LexerError,
UnclosedDelimiter {
delimiter: String,
},
MismatchedDelimiter {
expected: String,
found: String,
},
InvalidValue(ValueParsingError),
ReservedName {
name: String,
context: ReservedNameContext,
},
WrongDocumentKind {
found: DefinitionKind,
document_kind: DocumentKind,
},
InvalidEmptyConstruct {
construct: String,
},
InvalidSyntax,
}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§
UnexpectedToken
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
UnexpectedEof
Unexpected end of input while parsing.
The document ended before a complete construct was parsed.
§Example
type User {
^ expected `}`, found end of inputLexerError
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 literalUnclosedDelimiter
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 )).
MismatchedDelimiter
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
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 overflowReservedName
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.
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.
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.
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 more