Skip to content

Commit

Permalink
Fixed json scalar (ChilliCream#5941)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn authored and damienpontifex committed Mar 24, 2023
1 parent 2b916e3 commit c6c354d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Types/Types/Scalars/JsonType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected override ISyntaxVisitorAction Leave(
ListValueNode node,
JsonFormatterContext context)
{
context.Writer.WriteEndObject();
context.Writer.WriteEndArray();
return base.Enter(node, context);
}

Expand Down
28 changes: 28 additions & 0 deletions src/HotChocolate/Core/test/Types.Tests/Types/JsonTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,34 @@ public async Task Input_Json_Object_Literal()
""");
}

[Fact]
public async Task Input_Json_Object_List()
{
var result =
await new ServiceCollection()
.AddGraphQLServer()
.AddQueryType<Query>()
.ExecuteRequestAsync(
"""
{
inputJson(input: { a: ["abc"] })
}
""");

result.MatchInlineSnapshot(
"""
{
"data": {
"inputJson": {
"a": [
"abc"
]
}
}
}
""");
}

[Fact]
public async Task Input_Json_Object_Variables()
{
Expand Down

0 comments on commit c6c354d

Please sign in to comment.