Skip to content

Commit 4978f77

Browse files
committed
Allow late binding of subscribe resolvers. (#8287)
1 parent 2577941 commit 4978f77

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/HotChocolate/Core/src/Types/Types/ObjectField.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,24 @@ private set
7575
/// <summary>
7676
/// Gets the pure field resolver. The pure field resolver is only available if this field
7777
/// can be resolved without side effects. The execution engine will prefer this resolver
78-
/// variant if it is available and there are no executable directives that add a middleware
78+
/// variant if it is available, and there are no executable directives that add middleware
7979
/// to this field.
8080
/// </summary>
8181
public PureFieldDelegate? PureResolver { get; private set; }
8282

8383
/// <summary>
8484
/// Gets the subscription resolver.
8585
/// </summary>
86-
public SubscribeResolverDelegate? SubscribeResolver { get; }
86+
public SubscribeResolverDelegate? SubscribeResolver { get; private set; }
8787

8888
/// <summary>
89-
/// Gets the result post processor.
89+
/// Gets the result post-processor.
9090
/// </summary>
9191
public IResolverResultPostProcessor? ResultPostProcessor { get; private set; }
9292

9393
/// <summary>
9494
/// Gets the associated member of the runtime type for this field.
95-
/// This property can be <c>null</c> if this field is not associated to
95+
/// This property can be <c>null</c> if this field is not associated with
9696
/// a concrete member on the runtime type.
9797
/// </summary>
9898
public MemberInfo? Member { get; }
@@ -108,15 +108,18 @@ private set
108108
/// Gets the associated resolver expression.
109109
/// This expression can be <c>null</c>.
110110
/// </summary>
111-
public Expression? ResolverExpression { get; }
111+
public Expression? ResolverExpression { get; private set; }
112112

113113
protected override void OnMakeExecutable(
114114
ITypeCompletionContext context,
115115
ITypeSystemMember declaringMember,
116116
OutputFieldDefinitionBase definition)
117117
{
118+
var objectFieldDef = (ObjectFieldDefinition)definition;
118119
base.OnMakeExecutable(context, declaringMember, definition);
119-
CompleteResolver(context, (ObjectFieldDefinition)definition);
120+
CompleteResolver(context, objectFieldDef);
121+
ResolverExpression = objectFieldDef.Expression;
122+
SubscribeResolver = objectFieldDef.SubscribeResolver;
120123
}
121124

122125
private void CompleteResolver(
@@ -175,7 +178,7 @@ private void CompleteResolver(
175178
skipMiddleware);
176179
}
177180

178-
// by definition fields with pure resolvers are parallel executable.
181+
// by definition, fields with pure resolvers are parallel executable.
179182
if (!IsParallelExecutable && PureResolver is not null)
180183
{
181184
IsParallelExecutable = true;
@@ -203,7 +206,7 @@ private void CompleteResolver(
203206

204207
ResultPostProcessor = definition.ResultPostProcessor;
205208

206-
// if the source generator has configured this field we will not try to infer a post processor with
209+
// if the source generator has configured this field, we will not try to infer a post-processor with
207210
// reflection.
208211
if ((Flags & FieldFlags.SourceGenerator) != FieldFlags.SourceGenerator
209212
&& ResultPostProcessor is null

0 commit comments

Comments
 (0)