@@ -50,9 +50,9 @@ import type {
5050 SchemaExtensionNode ,
5151 SelectionNode ,
5252 SelectionSetNode ,
53- StringValueNode ,
5453 SemanticNonNullTypeNode ,
5554 SemanticNullableTypeNode ,
55+ StringValueNode ,
5656 Token ,
5757 TypeNode ,
5858 TypeSystemExtensionNode ,
@@ -109,10 +109,10 @@ export interface ParseOptions {
109109 /**
110110 * When enabled, the parser will understand and parse semantic nullability
111111 * annotations. This means that every type suffixed with `!` will remain
112- * non-nulllable , every type suffxed with `?` will be the classic nullable, and
112+ * non-nullable , every type suffixed with `?` will be the classic nullable, and
113113 * types without a suffix will be semantically nullable. Semantic nullability
114114 * will be the new default when this is enabled. A semantically nullable type
115- * can only be null when there's an error assocaited with the field.
115+ * can only be null when there's an error associated with the field.
116116 *
117117 * @experimental
118118 */
@@ -788,6 +788,25 @@ export class Parser {
788788 type = this . parseNamedType ( ) ;
789789 }
790790
791+ if ( this . _options . allowSemanticNullability ) {
792+ if ( this . expectOptionalToken ( TokenKind . BANG ) ) {
793+ return this . node < NonNullTypeNode > ( start , {
794+ kind : Kind . NON_NULL_TYPE ,
795+ type,
796+ } ) ;
797+ } else if ( this . expectOptionalToken ( TokenKind . QUESTION_MARK ) ) {
798+ return this . node < SemanticNullableTypeNode > ( start , {
799+ kind : Kind . SEMANTIC_NULLABLE_TYPE ,
800+ type,
801+ } ) ;
802+ }
803+
804+ return this . node < SemanticNonNullTypeNode > ( start , {
805+ kind : Kind . SEMANTIC_NON_NULL_TYPE ,
806+ type,
807+ } ) ;
808+ }
809+
791810 if ( this . expectOptionalToken ( TokenKind . BANG ) ) {
792811 return this . node < NonNullTypeNode > ( start , {
793812 kind : Kind . NON_NULL_TYPE ,
0 commit comments