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 @@ -108,6 +108,11 @@ private IOperation CompileOperation(
108
108
109
109
private bool IsNullBubblingEnabled ( IRequestContext context , OperationDefinitionNode operationDefinition )
110
110
{
111
+ if ( context . Schema . ContextData . ContainsKey ( DisableNullBubbling ) )
112
+ {
113
+ return false ;
114
+ }
115
+
111
116
if ( ! context . Schema . ContextData . ContainsKey ( EnableTrueNullability ) ||
112
117
operationDefinition . Directives . Count == 0 )
113
118
{
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public interface IReadOnlySchemaOptions
60
60
/// unreachable from the root types.
61
61
/// </summary>
62
62
bool RemoveUnreachableTypes { get ; }
63
-
63
+
64
64
/// <summary>
65
65
/// Defines if unused type system directives shall
66
66
/// be removed from the schema.
@@ -102,7 +102,7 @@ public interface IReadOnlySchemaOptions
102
102
/// Defines if the order of important middleware components shall be validated.
103
103
/// </summary>
104
104
bool ValidatePipelineOrder { get ; }
105
-
105
+
106
106
/// <summary>
107
107
/// Defines if the runtime types of types shall be validated.
108
108
/// </summary>
@@ -186,6 +186,11 @@ public interface IReadOnlySchemaOptions
186
186
/// </summary>
187
187
bool EnableTrueNullability { get ; }
188
188
189
+ /// <summary>
190
+ /// Specifies whether null-bubbling shall be disabled.
191
+ /// </summary>
192
+ bool DisableNullBubbling { get ; }
193
+
189
194
/// <summary>
190
195
/// Specifies that the @tag directive shall be registered with the type system.
191
196
/// </summary>
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ public partial class SchemaBuilder : ISchemaBuilder
37
37
typeof ( CostTypeInterceptor ) ,
38
38
typeof ( MiddlewareValidationTypeInterceptor ) ,
39
39
typeof ( EnableTrueNullabilityTypeInterceptor ) ,
40
+ typeof ( DisableNullBubblingTypeInterceptor ) ,
40
41
] ;
41
42
42
43
private SchemaOptions _options = new ( ) ;
@@ -261,7 +262,7 @@ public ISchemaBuilder AddType(INamedTypeExtension typeExtension)
261
262
_types . Add ( _ => TypeReference . Create ( typeExtension ) ) ;
262
263
return this ;
263
264
}
264
-
265
+
265
266
internal void AddTypeReference ( TypeReference typeReference )
266
267
{
267
268
if ( typeReference is null )
Original file line number Diff line number Diff line change @@ -221,6 +221,11 @@ public FieldBindingFlags DefaultFieldBindingFlags
221
221
/// </summary>
222
222
public bool EnableTrueNullability { get ; set ; }
223
223
224
+ /// <summary>
225
+ /// Specifies whether null-bubbling shall be disabled.
226
+ /// </summary>
227
+ public bool DisableNullBubbling { get ; set ; }
228
+
224
229
/// <summary>
225
230
/// Specifies that the @tag directive shall be registered with the type system.
226
231
/// </summary>
@@ -262,6 +267,7 @@ public static SchemaOptions FromOptions(IReadOnlySchemaOptions options)
262
267
MaxAllowedNodeBatchSize = options . MaxAllowedNodeBatchSize ,
263
268
StripLeadingIFromInterface = options . StripLeadingIFromInterface ,
264
269
EnableTrueNullability = options . EnableTrueNullability ,
270
+ DisableNullBubbling = options . DisableNullBubbling ,
265
271
EnableTag = options . EnableTag ,
266
272
} ;
267
273
}
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