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
274274 /// The key to access the authorization allowed flag on the member context.
275275 /// </summary>
276276 public const string AllowAnonymous = "HotChocolate.Authorization.AllowAnonymous" ;
277-
277+
278278 /// <summary>
279279 /// The key to access the true nullability flag on the execution context.
280280 /// </summary>
281281 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+
283288 /// <summary>
284289 /// The key to access the tag options object.
285290 /// </summary>
286291 public const string TagOptions = "HotChocolate.Types.TagOptions" ;
287-
292+
288293 /// <summary>
289294 /// Type key to access the internal schema options.
290295 /// </summary>
Original file line number Diff line number Diff line change @@ -108,6 +108,11 @@ private IOperation CompileOperation(
108108
109109 private bool IsNullBubblingEnabled ( IRequestContext context , OperationDefinitionNode operationDefinition )
110110 {
111+ if ( context . Schema . ContextData . ContainsKey ( DisableNullBubbling ) )
112+ {
113+ return false ;
114+ }
115+
111116 if ( ! context . Schema . ContextData . ContainsKey ( EnableTrueNullability ) ||
112117 operationDefinition . Directives . Count == 0 )
113118 {
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public interface IReadOnlySchemaOptions
6060 /// unreachable from the root types.
6161 /// </summary>
6262 bool RemoveUnreachableTypes { get ; }
63-
63+
6464 /// <summary>
6565 /// Defines if unused type system directives shall
6666 /// be removed from the schema.
@@ -102,7 +102,7 @@ public interface IReadOnlySchemaOptions
102102 /// Defines if the order of important middleware components shall be validated.
103103 /// </summary>
104104 bool ValidatePipelineOrder { get ; }
105-
105+
106106 /// <summary>
107107 /// Defines if the runtime types of types shall be validated.
108108 /// </summary>
@@ -186,6 +186,11 @@ public interface IReadOnlySchemaOptions
186186 /// </summary>
187187 bool EnableTrueNullability { get ; }
188188
189+ /// <summary>
190+ /// Specifies whether null-bubbling shall be disabled.
191+ /// </summary>
192+ bool DisableNullBubbling { get ; }
193+
189194 /// <summary>
190195 /// Specifies that the @tag directive shall be registered with the type system.
191196 /// </summary>
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ public partial class SchemaBuilder : ISchemaBuilder
3737 typeof ( CostTypeInterceptor ) ,
3838 typeof ( MiddlewareValidationTypeInterceptor ) ,
3939 typeof ( EnableTrueNullabilityTypeInterceptor ) ,
40+ typeof ( DisableNullBubblingTypeInterceptor ) ,
4041 ] ;
4142
4243 private SchemaOptions _options = new ( ) ;
@@ -261,7 +262,7 @@ public ISchemaBuilder AddType(INamedTypeExtension typeExtension)
261262 _types . Add ( _ => TypeReference . Create ( typeExtension ) ) ;
262263 return this ;
263264 }
264-
265+
265266 internal void AddTypeReference ( TypeReference typeReference )
266267 {
267268 if ( typeReference is null )
Original file line number Diff line number Diff line change @@ -221,6 +221,11 @@ public FieldBindingFlags DefaultFieldBindingFlags
221221 /// </summary>
222222 public bool EnableTrueNullability { get ; set ; }
223223
224+ /// <summary>
225+ /// Specifies whether null-bubbling shall be disabled.
226+ /// </summary>
227+ public bool DisableNullBubbling { get ; set ; }
228+
224229 /// <summary>
225230 /// Specifies that the @tag directive shall be registered with the type system.
226231 /// </summary>
@@ -262,6 +267,7 @@ public static SchemaOptions FromOptions(IReadOnlySchemaOptions options)
262267 MaxAllowedNodeBatchSize = options . MaxAllowedNodeBatchSize ,
263268 StripLeadingIFromInterface = options . StripLeadingIFromInterface ,
264269 EnableTrueNullability = options . EnableTrueNullability ,
270+ DisableNullBubbling = options . DisableNullBubbling ,
265271 EnableTag = options . EnableTag ,
266272 } ;
267273 }
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