File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
GraphQLParser.Tests/Visitors Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -813,6 +813,17 @@ public void UTF8_MemoryStream_Runs_Synchronously()
813813 printer . PrintAsync ( document , writer ) . IsCompletedSuccessfully . ShouldBeTrue ( ) ;
814814 }
815815
816+ [ Theory ]
817+ [ InlineData ( "{ field1 }" , "{\n field1\n }" ) ]
818+ [ InlineData ( "query { field1 }" , "{\n field1\n }" ) ]
819+ [ InlineData ( "query q1 { field1 }" , "query q1 {\n field1\n }" ) ]
820+ [ InlineData ( "mutation { field1 }" , "mutation {\n field1\n }" ) ]
821+ [ InlineData ( "mutation m1 { field1 }" , "mutation m1 {\n field1\n }" ) ]
822+ public void OperationPrints ( string input , string expected )
823+ {
824+ new SDLPrinter ( ) . Print ( Parser . Parse ( input ) ) . ShouldBe ( expected , StringCompareShould . IgnoreLineEndings ) ;
825+ }
826+
816827 [ Theory ]
817828 [ InlineData ( "query a { name }" ) ]
818829 [ InlineData ( "directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT" ) ]
Original file line number Diff line number Diff line change @@ -331,11 +331,14 @@ protected override async ValueTask VisitOperationDefinitionAsync(GraphQLOperatio
331331 }
332332
333333 await VisitAsync ( operationDefinition . Comments , context ) . ConfigureAwait ( false ) ;
334- if ( operationDefinition . Name is not null )
334+ if ( operationDefinition . Name is not null || operationDefinition . Operation != OperationType . Query )
335335 {
336336 await context . WriteAsync ( GetOperationType ( operationDefinition . Operation ) ) . ConfigureAwait ( false ) ;
337337 await context . WriteAsync ( " " ) . ConfigureAwait ( false ) ;
338- await VisitAsync ( operationDefinition . Name , context ) . ConfigureAwait ( false ) ;
338+ if ( operationDefinition . Name is not null )
339+ {
340+ await VisitAsync ( operationDefinition . Name , context ) . ConfigureAwait ( false ) ;
341+ }
339342 }
340343 await VisitAsync ( operationDefinition . Variables , context ) . ConfigureAwait ( false ) ;
341344 await VisitAsync ( operationDefinition . Directives , context ) . ConfigureAwait ( false ) ;
You can’t perform that action at this time.
0 commit comments