@@ -253,7 +253,7 @@ make_parser!(
253
253
254
254
make_parser ! (
255
255
OperationDefinition ( input: char ) -> Operation {
256
- OperationTypeParserarser :: new( )
256
+ OperationTypeParser :: new( )
257
257
. and( optional( NameParser :: new( ) ) )
258
258
. and( optional( VariableDefinitions :: new( ) ) )
259
259
. map( |( ( op_type, name) , defns) | {
@@ -264,12 +264,13 @@ make_parser!(
264
264
265
265
Operation :: new( op_type, name, variable_definitions, Vec :: new( ) )
266
266
} )
267
+ . skip( many:: <Vec <_>, _>( or( WhiteSpace :: new( ) , LineTerminator :: new( & true ) ) ) )
267
268
. parse_stream( input)
268
269
}
269
270
) ;
270
271
271
272
make_parser ! (
272
- OperationTypeParserarser ( input: char ) -> OperationType {
273
+ OperationTypeParser ( input: char ) -> OperationType {
273
274
string( "query" ) . map( |_| OperationType :: Query )
274
275
. or( string( "mutation" ) . map( |_| OperationType :: Mutation ) )
275
276
. skip( many:: <Vec <_>, _>( or( WhiteSpace :: new( ) , LineTerminator :: new( & true ) ) ) )
@@ -297,18 +298,21 @@ make_parser!(
297
298
298
299
make_parser ! (
299
300
VariableDefinitions ( input: char ) -> Vec <VariableDefinition > {
300
- between( char ( '(' ) , char ( ')' ) , many( VariableDefinitionP :: new( ) ) )
301
+ between( char ( '(' ) , char ( ')' ) , many( VariableDefinitionParser :: new( ) ) )
301
302
. parse_stream( input)
302
303
}
303
304
) ;
304
305
305
306
make_parser ! (
306
- VariableDefinitionP ( input: char ) -> VariableDefinition {
307
+ VariableDefinitionParser ( input: char ) -> VariableDefinition {
307
308
VariableParser :: new( )
309
+ . skip( char ( ':' ) )
310
+ . skip( many:: <Vec <_>, _>( or( WhiteSpace :: new( ) , LineTerminator :: new( & true ) ) ) )
308
311
. and( TypeParser :: new( ) )
309
312
. map( |( variable, var_type) | {
310
313
VariableDefinition :: new( variable, var_type, None )
311
314
} )
315
+ . skip( many:: <Vec <_>, _>( or( WhiteSpace :: new( ) , LineTerminator :: new( & true ) ) ) )
312
316
. parse_stream( input)
313
317
}
314
318
) ;
@@ -343,8 +347,8 @@ make_parser!(
343
347
make_parser ! (
344
348
Alias ( input: char ) -> Name {
345
349
NameParser :: new( )
346
- . skip( many:: <Vec <_>, _>( or( WhiteSpace :: new( ) , LineTerminator :: new( & true ) ) ) )
347
350
. skip( char ( ':' ) )
351
+ . skip( many:: <Vec <_>, _>( or( WhiteSpace :: new( ) , LineTerminator :: new( & true ) ) ) )
348
352
. parse_stream( input)
349
353
}
350
354
) ;
@@ -367,10 +371,8 @@ mod tests {
367
371
368
372
#[ test]
369
373
fn test_parse_operationtype ( ) {
370
- assert_successful_parse ! ( OperationTypeParserarser , "query" , OperationType :: Query ) ;
371
- assert_successful_parse ! ( OperationTypeParserarser ,
372
- "mutation" ,
373
- OperationType :: Mutation ) ;
374
+ assert_successful_parse ! ( OperationTypeParser , "query" , OperationType :: Query ) ;
375
+ assert_successful_parse ! ( OperationTypeParser , "mutation" , OperationType :: Mutation ) ;
374
376
}
375
377
376
378
#[ test]
@@ -424,4 +426,11 @@ mod tests {
424
426
"![User]" ,
425
427
Type :: NonNull ( Box :: new( Type :: List ( Box :: new( Type :: Named ( String :: from( "User" ) ) ) ) ) ) ) ;
426
428
}
429
+
430
+ #[ test]
431
+ fn test_parse_variabledefinition_nodefaultvalue ( ) {
432
+ assert_successful_parse ! ( VariableDefinitionParser ,
433
+ "$devicePicSize: Int" ,
434
+ VariableDefinition :: new( String :: from( "devicePicSize" ) , Type :: Named ( String :: from( "Int" ) ) , None ) ) ;
435
+ }
427
436
}
0 commit comments