Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ private static void WriteDictionary(

foreach (var item in dict)
{
if (item.Value is null)
{
continue;
}

writer.WritePropertyName(item.Key);
WriteFieldValue(writer, item.Value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Text;
using System.Text.Json;
using CookieCrumble;
using Moq;

namespace HotChocolate.Transport.Http.Tests;

public class OperationRequestTests
{
[Fact]
public async Task Should_WriteNullValues()
{
// arrange
var request = new OperationRequest(
null,
"abc",
"myOperation",
variables: new Dictionary<string, object?>()
{
["abc"] = "def",
["hij"] = null
});

using var memory = new MemoryStream();
await using var writer = new Utf8JsonWriter(memory);

// act
request.WriteTo(writer);
await writer.FlushAsync();

// assert
var result = Encoding.UTF8.GetString(memory.ToArray());
Assert.Equal(
"""{"id":"abc","operationName":"myOperation","variables":{"abc":"def","hij":null}}""",
result);
}
}