@@ -784,14 +784,14 @@ function parseOperationTypeDefinition(
784
784
}
785
785
786
786
/**
787
- * ScalarTypeDefinition : scalar Name ScalarOfType ? Directives?
788
- * ScalarOfType : = NamedType
787
+ * ScalarTypeDefinition : scalar Name SerializeAsType ? Directives?
788
+ * SerializeAsType : as NamedType
789
789
*/
790
790
function parseScalarTypeDefinition ( lexer : Lexer < * > ) : ScalarTypeDefinitionNode {
791
791
const start = lexer . token ;
792
792
expectKeyword ( lexer , 'scalar' ) ;
793
793
const name = parseName ( lexer ) ;
794
- const type = skip ( lexer , TokenKind . EQUALS ) ? parseNamedType ( lexer ) : null ;
794
+ const type = skipKeyword ( lexer , 'as' ) ? parseNamedType ( lexer ) : null ;
795
795
const directives = parseDirectives ( lexer ) ;
796
796
return {
797
797
kind : SCALAR_TYPE_DEFINITION ,
@@ -1133,10 +1133,24 @@ function expect(lexer: Lexer<*>, kind: string): Token {
1133
1133
}
1134
1134
1135
1135
/**
1136
- * If the next token is a keyword with the given value, return that token after
1136
+ * If the next token is a keyword with the given value, return true after
1137
1137
* advancing the lexer. Otherwise, do not change the parser state and return
1138
1138
* false.
1139
1139
*/
1140
+ function skipKeyword ( lexer : Lexer < * > , value : string ) : boolean {
1141
+ const token = lexer . token ;
1142
+ const match = token . kind === TokenKind . NAME && token . value === value ;
1143
+ if ( match ) {
1144
+ lexer . advance ( ) ;
1145
+ }
1146
+ return match ;
1147
+ }
1148
+
1149
+ /**
1150
+ * If the next token is a keyword with the given value, return that token after
1151
+ * advancing the lexer. Otherwise, do not change the parser state and throw
1152
+ * an error.
1153
+ */
1140
1154
function expectKeyword ( lexer : Lexer < * > , value : string ) : Token {
1141
1155
const token = lexer . token ;
1142
1156
if ( token . kind === TokenKind . NAME && token . value === value ) {
0 commit comments