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()
813
813
printer . PrintAsync ( document , writer ) . IsCompletedSuccessfully . ShouldBeTrue ( ) ;
814
814
}
815
815
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
+
816
827
[ Theory ]
817
828
[ InlineData ( "query a { name }" ) ]
818
829
[ 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
331
331
}
332
332
333
333
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 )
335
335
{
336
336
await context . WriteAsync ( GetOperationType ( operationDefinition . Operation ) ) . ConfigureAwait ( false ) ;
337
337
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
+ }
339
342
}
340
343
await VisitAsync ( operationDefinition . Variables , context ) . ConfigureAwait ( false ) ;
341
344
await VisitAsync ( operationDefinition . Directives , context ) . ConfigureAwait ( false ) ;
You can’t perform that action at this time.
0 commit comments