Skip to content

Commit 8157dc5

Browse files
Add simple test
1 parent ef8d1b3 commit 8157dc5

File tree

2 files changed

+68
-16
lines changed

2 files changed

+68
-16
lines changed

src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public async Task Schema_Without_TrueNullability()
1515
.AddQueryType<Query>()
1616
.ModifyOptions(o => o.EnableTrueNullability = false)
1717
.BuildSchemaAsync();
18-
18+
1919
schema.MatchSnapshot();
2020
}
21-
21+
2222
[Fact]
2323
public async Task Schema_With_TrueNullability()
2424
{
@@ -28,10 +28,10 @@ public async Task Schema_With_TrueNullability()
2828
.AddQueryType<Query>()
2929
.ModifyOptions(o => o.EnableTrueNullability = true)
3030
.BuildSchemaAsync();
31-
31+
3232
schema.MatchSnapshot();
3333
}
34-
34+
3535
[Fact]
3636
public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled_By_Default()
3737
{
@@ -51,10 +51,10 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled_By_D
5151
}
5252
}
5353
""");
54-
54+
5555
response.MatchSnapshot();
5656
}
57-
57+
5858
[Fact]
5959
public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled()
6060
{
@@ -74,10 +74,10 @@ query @nullBubbling {
7474
}
7575
}
7676
""");
77-
77+
7878
response.MatchSnapshot();
7979
}
80-
80+
8181
[Fact]
8282
public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled()
8383
{
@@ -97,10 +97,10 @@ query @nullBubbling(enable: false) {
9797
}
9898
}
9999
""");
100-
100+
101101
response.MatchSnapshot();
102102
}
103-
103+
104104
[Fact]
105105
public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable()
106106
{
@@ -124,24 +124,50 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled_Wit
124124
""")
125125
.SetVariableValue("enable", false)
126126
.Create());
127-
127+
128+
response.MatchSnapshot();
129+
}
130+
131+
[Fact]
132+
public async Task Error_Query_With_NullBubbling_Disabled()
133+
{
134+
var request = QueryRequestBuilder.New()
135+
.SetQuery("""
136+
query {
137+
book {
138+
name
139+
author {
140+
name
141+
}
142+
}
143+
}
144+
""")
145+
.TryAddGlobalState(WellKnownContextData.DisableNullBubbling, true)
146+
.Create();
147+
148+
var response =
149+
await new ServiceCollection()
150+
.AddGraphQLServer()
151+
.AddQueryType<Query>()
152+
.ExecuteRequestAsync(request);
153+
128154
response.MatchSnapshot();
129155
}
130-
156+
131157
public class Query
132158
{
133159
public Book? GetBook() => new();
134160
}
135-
161+
136162
public class Book
137163
{
138164
public string Name => "Some book!";
139165

140166
public Author Author => new();
141167
}
142-
168+
143169
public class Author
144170
{
145171
public string Name => throw new Exception();
146-
}
147-
}
172+
}
173+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"errors": [
3+
{
4+
"message": "Unexpected Execution Error",
5+
"locations": [
6+
{
7+
"line": 5,
8+
"column": 13
9+
}
10+
],
11+
"path": [
12+
"book",
13+
"author",
14+
"name"
15+
]
16+
}
17+
],
18+
"data": {
19+
"book": {
20+
"name": "Some book!",
21+
"author": {
22+
"name": null
23+
}
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)