Skip to content

Commit de34c86

Browse files
authored
[Fusion] Avoid writing log entries as GraphQL comments when unnecessary (#8257)
1 parent d1f2830 commit de34c86

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/HotChocolate/Fusion-vnext/src/Fusion.CommandLine/Commands/ComposeCommand.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.CommandLine.IO;
44
using System.Text;
55
using HotChocolate.Fusion.Logging;
6-
using HotChocolate.Fusion.Results;
7-
using HotChocolate.Types.Mutable;
86
using static HotChocolate.Fusion.Properties.CommandLineResources;
97

108
namespace HotChocolate.Fusion.Commands;
@@ -97,7 +95,10 @@ private static async Task<int> ExecuteAsync(
9795

9896
var result = schemaComposer.Compose();
9997

100-
WriteCompositionLog(compositionLog, console, result);
98+
WriteCompositionLog(
99+
compositionLog,
100+
writer: result.IsSuccess ? console.Out : console.Error,
101+
writeAsGraphQLComments: result.IsSuccess && compositeSchemaFile is null);
101102

102103
if (result.IsFailure)
103104
{
@@ -138,11 +139,10 @@ await File.WriteAllTextAsync(
138139

139140
private static void WriteCompositionLog(
140141
CompositionLog compositionLog,
141-
IConsole console,
142-
CompositionResult<MutableSchemaDefinition> result)
142+
IStandardStreamWriter writer,
143+
bool writeAsGraphQLComments)
143144
{
144145
Console.OutputEncoding = Encoding.UTF8;
145-
var writer = result.IsSuccess ? console.Out : console.Error;
146146

147147
foreach (var entry in compositionLog)
148148
{
@@ -164,8 +164,7 @@ private static void WriteCompositionLog(
164164

165165
var message = $"{emoji} [{abbreviatedSeverity}] {entry.Message} ({entry.Code})";
166166

167-
// When the composition is successful, write log entries as GraphQL comments.
168-
if (result.IsSuccess)
167+
if (writeAsGraphQLComments)
169168
{
170169
message = $"# {message}";
171170
}

0 commit comments

Comments
 (0)