2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Threading . Tasks ;
5
+ using HotChocolate . Execution . Options ;
5
6
using HotChocolate . Execution . Processing ;
6
7
using HotChocolate . Language ;
7
8
using HotChocolate . Types ;
@@ -19,13 +20,15 @@ internal sealed class OperationResolverMiddleware
19
20
{
20
21
private readonly RequestDelegate _next ;
21
22
private readonly ObjectPool < OperationCompiler > _operationCompilerPool ;
23
+ private readonly IRequestExecutorOptionsAccessor _options ;
22
24
private readonly VariableCoercionHelper _coercionHelper ;
23
25
private readonly IReadOnlyList < IOperationCompilerOptimizer > ? _optimizers ;
24
26
25
27
private OperationResolverMiddleware (
26
28
RequestDelegate next ,
27
29
ObjectPool < OperationCompiler > operationCompilerPool ,
28
30
IEnumerable < IOperationCompilerOptimizer > optimizers ,
31
+ IRequestExecutorOptionsAccessor options ,
29
32
VariableCoercionHelper coercionHelper )
30
33
{
31
34
if ( optimizers is null )
@@ -37,6 +40,8 @@ private OperationResolverMiddleware(
37
40
throw new ArgumentNullException ( nameof ( next ) ) ;
38
41
_operationCompilerPool = operationCompilerPool ??
39
42
throw new ArgumentNullException ( nameof ( operationCompilerPool ) ) ;
43
+ _options = options ??
44
+ throw new ArgumentNullException ( nameof ( options ) ) ;
40
45
_coercionHelper = coercionHelper ??
41
46
throw new ArgumentNullException ( nameof ( coercionHelper ) ) ;
42
47
_optimizers = optimizers . ToArray ( ) ;
@@ -109,8 +114,7 @@ private IOperation CompileOperation(
109
114
110
115
private bool IsNullBubblingEnabled ( IRequestContext context , OperationDefinitionNode operationDefinition )
111
116
{
112
- if ( context . ContextData . TryGetValue ( DisableNullBubbling , out var disableNullBubbling )
113
- && disableNullBubbling is true )
117
+ if ( _options . AllowDisablingNullBubbling && context . ContextData . ContainsKey ( DisableNullBubbling ) )
114
118
{
115
119
return false ;
116
120
}
@@ -175,12 +179,14 @@ public static RequestCoreMiddleware Create()
175
179
var operationCompilerPool = core . Services . GetRequiredService < ObjectPool < OperationCompiler > > ( ) ;
176
180
var optimizers1 = core . Services . GetRequiredService < IEnumerable < IOperationCompilerOptimizer > > ( ) ;
177
181
var optimizers2 = core . SchemaServices . GetRequiredService < IEnumerable < IOperationCompilerOptimizer > > ( ) ;
182
+ var options = core . SchemaServices . GetRequiredService < IRequestExecutorOptionsAccessor > ( ) ;
178
183
var coercionHelper = core . Services . GetRequiredService < VariableCoercionHelper > ( ) ;
179
184
var middleware = new OperationResolverMiddleware (
180
185
next ,
181
186
operationCompilerPool ,
182
187
optimizers1 . Concat ( optimizers2 ) ,
188
+ options ,
183
189
coercionHelper ) ;
184
190
return context => middleware . InvokeAsync ( context ) ;
185
191
} ;
186
- }
192
+ }
0 commit comments