diff --git a/src/HotChocolate/Language/test/Language.SyntaxTree.Tests/Utilities/SchemaSyntaxPrinterTests.cs b/src/HotChocolate/Language/test/Language.SyntaxTree.Tests/Utilities/SchemaSyntaxPrinterTests.cs index acdde6158f0..d32ab51d881 100644 --- a/src/HotChocolate/Language/test/Language.SyntaxTree.Tests/Utilities/SchemaSyntaxPrinterTests.cs +++ b/src/HotChocolate/Language/test/Language.SyntaxTree.Tests/Utilities/SchemaSyntaxPrinterTests.cs @@ -716,6 +716,35 @@ public void Serialize_SchemaDefWithOpNoIndent_InOutShouldBeTheSame() Assert.Equal(schema, result); } + [Fact] + public void Serialize_SchemaDefWithDescriptionAndOps_SchemaKeywordNotOmitted() + { + // arrange + var schema = + """ + "Example schema" + schema { + query: Query + mutation: Mutation + } + + type Query { + someField: String + } + + type Mutation { + someMutation: String + } + """; + var document = Utf8GraphQLParser.Parse(schema); + + // act + var result = document.ToString(); + + // assert + result.MatchInlineSnapshot(schema); + } + [Fact] public void Serialize_SchemaDefWithOpNoIndent_OutHasIndentation() { diff --git a/src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaFormatterTests.cs b/src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaFormatterTests.cs index 937ae9884e4..014f095a1d8 100644 --- a/src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaFormatterTests.cs +++ b/src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaFormatterTests.cs @@ -293,4 +293,34 @@ input Bar { } """); } + + [Fact] + public void Format_Schema_With_Description_Schema_Keyword_Not_Omitted() + { + // arrange + var sdl = + """ + "Example schema" + schema { + query: Query + mutation: Mutation + } + + type Query { + someField: String + } + + type Mutation { + someMutation: String + } + """; + + var schema = SchemaParser.Parse(Encoding.UTF8.GetBytes(sdl)); + + // act + var formattedSdl = SchemaFormatter.FormatAsString(schema); + + // assert + formattedSdl.MatchInlineSnapshot(sdl); + } }