Skip to content

Commit 8105092

Browse files
committed
Added test for { a: null }
1 parent 0886871 commit 8105092

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/HotChocolate/Core/test/Types.Tests/Types/OneOfIntegrationTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ public async Task A_is_null_and_B_is_set_Error()
3434
.MatchSnapshotAsync();
3535
}
3636

37+
[Fact]
38+
public async Task A_is_null_Error()
39+
{
40+
// Error: Value for member field {a} must be non-null
41+
await new ServiceCollection()
42+
.AddGraphQL()
43+
.AddQueryType<Query>()
44+
.ModifyOptions(o => o.EnableOneOf = true)
45+
.ExecuteRequestAsync("{ example(input: { a: null }) }")
46+
.MatchSnapshotAsync();
47+
}
48+
3749
[Fact]
3850
public async Task B_is_set_Valid()
3951
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"errors": [
3+
{
4+
"message": "The OneOf Input Object `ExampleInput` requires that exactly one field must be supplied and that field must not be `null`.",
5+
"locations": [
6+
{
7+
"line": 1,
8+
"column": 18
9+
}
10+
],
11+
"path": [
12+
"example"
13+
],
14+
"extensions": {
15+
"type": "ExampleInput",
16+
"specifiedBy": "https://spec.graphql.org/draft/#sec-OneOf-Input-Objects-Have-Exactly-One-Field",
17+
"rfc": "https://github.com/graphql/graphql-spec/pull/825"
18+
}
19+
}
20+
]
21+
}

0 commit comments

Comments
 (0)