Skip to content

Commit 0419954

Browse files
authored
Demonstrate issue 3233 (graphql-dotnet#3256)
1 parent 431db6f commit 0419954

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/GraphQL.Tests/Bugs/Issue3233.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace GraphQL.Tests.Bugs;
2+
3+
public class Issue3233
4+
{
5+
[Fact]
6+
public void Throws_NotSupportedException_On_Object_Key()
7+
{
8+
var serializer = new SystemTextJson.GraphQLSerializer();
9+
var result = new ExecutionResult();
10+
result.AddError(new ExecutionError("oops1"));
11+
var serialized = serializer.Serialize(result);
12+
serialized.ShouldBe("{\"errors\":[{\"message\":\"oops1\"}]}");
13+
14+
result = new ExecutionResult();
15+
var errorWithData = new ExecutionError("oops2");
16+
errorWithData.Data.Add(new object(), "WOW");
17+
result.AddError(errorWithData);
18+
19+
var ex = Should.Throw<NotSupportedException>(() => serializer.Serialize(result));
20+
var messages = new[]
21+
{
22+
"The type 'System.Object' is not a supported Dictionary key type. Path: $.",
23+
"The type 'System.Object' is not a supported dictionary key using converter of type 'System.Text.Json.Serialization.Converters.ObjectConverter'. Path: $.",
24+
"The collection type 'System.Collections.ListDictionaryInternal' is not supported."
25+
};
26+
if (!messages.Contains(ex.Message))
27+
throw ex;
28+
}
29+
}

0 commit comments

Comments
 (0)