diff --git a/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs b/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs index 512ce55b61d..09ded9bb63b 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/TrueNullabilityTests.cs @@ -15,10 +15,10 @@ public async Task Schema_Without_TrueNullability() .AddQueryType() .ModifyOptions(o => o.EnableTrueNullability = false) .BuildSchemaAsync(); - + schema.MatchSnapshot(); } - + [Fact] public async Task Schema_With_TrueNullability() { @@ -28,10 +28,10 @@ public async Task Schema_With_TrueNullability() .AddQueryType() .ModifyOptions(o => o.EnableTrueNullability = true) .BuildSchemaAsync(); - + schema.MatchSnapshot(); } - + [Fact] public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled_By_Default() { @@ -51,10 +51,10 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled_By_D } } """); - + response.MatchSnapshot(); } - + [Fact] public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled() { @@ -74,10 +74,10 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Enabled() } } """); - + response.MatchSnapshot(); } - + [Fact] public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled() { @@ -97,10 +97,10 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled() } } """); - + response.MatchSnapshot(); } - + [Fact] public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled_With_Variable() { @@ -124,24 +124,50 @@ public async Task Error_Query_With_TrueNullability_And_NullBubbling_Disabled_Wit """) .SetVariableValue("enable", false) .Create()); - + + response.MatchSnapshot(); + } + + [Fact] + public async Task Error_Query_With_NullBubbling_Disabled() + { + var request = QueryRequestBuilder.New() + .SetQuery(""" + query { + book { + name + author { + name + } + } + } + """) + .TryAddGlobalState(WellKnownContextData.DisableNullBubbling, true) + .Create(); + + var response = + await new ServiceCollection() + .AddGraphQLServer() + .AddQueryType() + .ExecuteRequestAsync(request); + response.MatchSnapshot(); } - + public class Query { public Book? GetBook() => new(); } - + public class Book { public string Name => "Some book!"; public Author Author => new(); } - + public class Author { public string Name => throw new Exception(); - } -} \ No newline at end of file + } +} diff --git a/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_NullBubbling_Disabled.snap b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_NullBubbling_Disabled.snap new file mode 100644 index 00000000000..5f1271ea8b6 --- /dev/null +++ b/src/HotChocolate/Core/test/Execution.Tests/__snapshots__/TrueNullabilityTests.Error_Query_With_NullBubbling_Disabled.snap @@ -0,0 +1,26 @@ +{ + "errors": [ + { + "message": "Unexpected Execution Error", + "locations": [ + { + "line": 5, + "column": 13 + } + ], + "path": [ + "book", + "author", + "name" + ] + } + ], + "data": { + "book": { + "name": "Some book!", + "author": { + "name": null + } + } + } +} \ No newline at end of file