libgraphql_parser/ast/nullability.rs
1use crate::token::GraphQLToken;
2
3/// The nullability of a
4/// [type reference](https://spec.graphql.org/September2025/#sec-Type-References).
5///
6/// Rather than modeling `NonNullType` as a recursive enum variant (which would allow redundant
7/// same-level wrapping like `NonNull(NonNull(...))`), nullability is flattened into this enum on
8/// each concrete type annotation node.
9///
10/// Multi-level `NonNull` (e.g. `[String!]!`) is fully supported: the inner `String!` is the list's
11/// `element_type` (a separate [`TypeAnnotation`](crate::ast::TypeAnnotation) with its own
12/// `Nullability`), and the outer `!` is on the
13/// [`ListTypeAnnotation`](crate::ast::ListTypeAnnotation).
14#[derive(Clone, Debug, PartialEq)]
15pub enum Nullability<'src> {
16 NonNull {
17 /// The `!` token. Present when syntax detail is
18 /// retained.
19 syntax: Option<GraphQLToken<'src>>,
20 },
21 Nullable,
22}