File tree Expand file tree Collapse file tree 6 files changed +48
-6
lines changed
src/HotChocolate/Core/src Expand file tree Collapse file tree 6 files changed +48
-6
lines changed Original file line number Diff line number Diff line change @@ -274,17 +274,22 @@ public static class WellKnownContextData
274
274
/// The key to access the authorization allowed flag on the member context.
275
275
/// </summary>
276
276
public const string AllowAnonymous = "HotChocolate.Authorization.AllowAnonymous" ;
277
-
277
+
278
278
/// <summary>
279
279
/// The key to access the true nullability flag on the execution context.
280
280
/// </summary>
281
281
public const string EnableTrueNullability = "HotChocolate.Types.EnableTrueNullability" ;
282
-
282
+
283
+ /// <summary>
284
+ /// The key to access the disable null-bubbling flag on the execution context.
285
+ /// </summary>
286
+ public const string DisableNullBubbling = "HotChocolate.Types.DisableNullBubbling" ;
287
+
283
288
/// <summary>
284
289
/// The key to access the tag options object.
285
290
/// </summary>
286
291
public const string TagOptions = "HotChocolate.Types.TagOptions" ;
287
-
292
+
288
293
/// <summary>
289
294
/// Type key to access the internal schema options.
290
295
/// </summary>
Original file line number Diff line number Diff line change @@ -109,6 +109,11 @@ private IOperation CompileOperation(
109
109
110
110
private bool IsNullBubblingEnabled ( IRequestContext context , OperationDefinitionNode operationDefinition )
111
111
{
112
+ if ( context . Schema . ContextData . ContainsKey ( DisableNullBubbling ) )
113
+ {
114
+ return false ;
115
+ }
116
+
112
117
if ( ! context . Schema . ContextData . ContainsKey ( EnableTrueNullability ) ||
113
118
operationDefinition . Directives . Count == 0 )
114
119
{
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public interface IReadOnlySchemaOptions
55
55
/// unreachable from the root types.
56
56
/// </summary>
57
57
bool RemoveUnreachableTypes { get ; }
58
-
58
+
59
59
/// <summary>
60
60
/// Defines if unused type system directives shall
61
61
/// be removed from the schema.
@@ -97,7 +97,7 @@ public interface IReadOnlySchemaOptions
97
97
/// Defines if the order of important middleware components shall be validated.
98
98
/// </summary>
99
99
bool ValidatePipelineOrder { get ; }
100
-
100
+
101
101
/// <summary>
102
102
/// Defines if the runtime types of types shall be validated.
103
103
/// </summary>
@@ -181,6 +181,11 @@ public interface IReadOnlySchemaOptions
181
181
/// </summary>
182
182
bool EnableTrueNullability { get ; }
183
183
184
+ /// <summary>
185
+ /// Specifies whether null-bubbling shall be disabled.
186
+ /// </summary>
187
+ bool DisableNullBubbling { get ; }
188
+
184
189
/// <summary>
185
190
/// Specifies that the @tag directive shall be registered with the type system.
186
191
/// </summary>
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ public partial class SchemaBuilder : ISchemaBuilder
39
39
typeof ( CostTypeInterceptor ) ,
40
40
typeof ( MiddlewareValidationTypeInterceptor ) ,
41
41
typeof ( EnableTrueNullabilityTypeInterceptor ) ,
42
+ typeof ( DisableNullBubblingTypeInterceptor ) ,
42
43
] ;
43
44
44
45
private SchemaOptions _options = new ( ) ;
@@ -263,7 +264,7 @@ public ISchemaBuilder AddType(INamedTypeExtension typeExtension)
263
264
_types . Add ( _ => TypeReference . Create ( typeExtension ) ) ;
264
265
return this ;
265
266
}
266
-
267
+
267
268
internal void AddTypeReference ( TypeReference typeReference )
268
269
{
269
270
if ( typeReference is null )
Original file line number Diff line number Diff line change @@ -211,6 +211,11 @@ public FieldBindingFlags DefaultFieldBindingFlags
211
211
/// </summary>
212
212
public bool EnableTrueNullability { get ; set ; }
213
213
214
+ /// <summary>
215
+ /// Specifies whether null-bubbling shall be disabled.
216
+ /// </summary>
217
+ public bool DisableNullBubbling { get ; set ; }
218
+
214
219
/// <summary>
215
220
/// Specifies that the @tag directive shall be registered with the type system.
216
221
/// </summary>
@@ -263,6 +268,7 @@ public static SchemaOptions FromOptions(IReadOnlySchemaOptions options)
263
268
MaxAllowedNodeBatchSize = options . MaxAllowedNodeBatchSize ,
264
269
StripLeadingIFromInterface = options . StripLeadingIFromInterface ,
265
270
EnableTrueNullability = options . EnableTrueNullability ,
271
+ DisableNullBubbling = options . DisableNullBubbling ,
266
272
EnableTag = options . EnableTag ,
267
273
DefaultQueryDependencyInjectionScope = options . DefaultQueryDependencyInjectionScope ,
268
274
DefaultMutationDependencyInjectionScope = options . DefaultMutationDependencyInjectionScope ,
Original file line number Diff line number Diff line change
1
+ #nullable enable
2
+ using HotChocolate . Configuration ;
3
+ using HotChocolate . Types . Descriptors ;
4
+ using HotChocolate . Types . Descriptors . Definitions ;
5
+
6
+ namespace HotChocolate . Types . Interceptors ;
7
+
8
+ internal sealed class DisableNullBubblingTypeInterceptor : TypeInterceptor
9
+ {
10
+ internal override bool IsEnabled ( IDescriptorContext context )
11
+ => context . Options . DisableNullBubbling ;
12
+
13
+ public override void OnAfterInitialize ( ITypeDiscoveryContext discoveryContext , DefinitionBase definition )
14
+ {
15
+ if ( definition is SchemaTypeDefinition schemaDef )
16
+ {
17
+ schemaDef . ContextData [ WellKnownContextData . DisableNullBubbling ] = true ;
18
+ }
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments