@@ -104,18 +104,6 @@ export interface ParseOptions {
104104 * ```
105105 */
106106 allowLegacyFragmentVariables ?: boolean ;
107-
108- /**
109- * When enabled, the parser will understand and parse semantic nullability
110- * annotations. This means that every type suffixed with `!` will remain
111- * non-nullable, every type suffixed with `?` will be the classic nullable, and
112- * types without a suffix will be semantically nullable. Semantic nullability
113- * will be the new default when this is enabled. A semantically nullable type
114- * can only be null when there's an error associated with the field.
115- *
116- * @experimental
117- */
118- allowSemanticNullability ?: boolean ;
119107}
120108
121109/**
@@ -271,16 +259,6 @@ export class Parser {
271259 * - InputObjectTypeDefinition
272260 */
273261 parseDefinition ( ) : DefinitionNode {
274- const directives = this . parseDirectives ( false ) ;
275- // If a document-level SemanticNullability directive exists as
276- // the first element in a document, then all parsing will
277- // happen in SemanticNullability mode.
278- for ( const directive of directives ) {
279- if ( directive . name . value === 'SemanticNullability' ) {
280- this . _options . allowSemanticNullability = true ;
281- }
282- }
283-
284262 if ( this . peek ( TokenKind . BRACE_L ) ) {
285263 return this . parseOperationDefinition ( ) ;
286264 }
@@ -788,27 +766,16 @@ export class Parser {
788766 type = this . parseNamedType ( ) ;
789767 }
790768
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 type ;
799- }
800-
801- return this . node < SemanticNonNullTypeNode > ( start , {
802- kind : Kind . SEMANTIC_NON_NULL_TYPE ,
803- type,
804- } ) ;
805- }
806-
807769 if ( this . expectOptionalToken ( TokenKind . BANG ) ) {
808770 return this . node < NonNullTypeNode > ( start , {
809771 kind : Kind . NON_NULL_TYPE ,
810772 type,
811773 } ) ;
774+ } else if ( this . expectOptionalToken ( TokenKind . STAR ) ) {
775+ return this . node < SemanticNonNullTypeNode > ( start , {
776+ kind : Kind . SEMANTIC_NON_NULL_TYPE ,
777+ type,
778+ } ) ;
812779 }
813780
814781 return type ;
0 commit comments