Skip to content

Commit a14b67a

Browse files
authored
Document executor-type changes in v15→v16 migration guide (#9736)
1 parent 7f8e6b8 commit a14b67a

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,60 @@ public class CustomRequestMiddleware
236236
}
237237
```
238238

239+
## IRequestExecutorResolver split into provider, events, and manager
240+
241+
The single `IRequestExecutorResolver` interface from v15 has been removed and its responsibilities split across three more focused abstractions in `HotChocolate.Execution.Abstractions`:
242+
243+
| v15 (`IRequestExecutorResolver`) | v16 |
244+
| ------------------------------------- | ------------------------------------------------------------------------------ |
245+
| `GetRequestExecutorAsync(schemaName)` | `IRequestExecutorProvider.GetExecutorAsync(schemaName)` |
246+
| `Events` (`IObservable<…>`) | `IRequestExecutorEvents` (which itself is `IObservable<RequestExecutorEvent>`) |
247+
| `EvictRequestExecutor(schemaName)` | `IRequestExecutorManager.EvictExecutor(schemaName)` |
248+
249+
`IRequestExecutorManager` derives from `IRequestExecutorProvider`, so inject the manager when you need both lookup and eviction, the provider when you only need lookup, and `IRequestExecutorEvents` when you only need to react to executor lifecycle events:
250+
251+
```diff
252+
-public class MyService(IRequestExecutorResolver resolver)
253+
+public class MyService(
254+
+ IRequestExecutorManager executors,
255+
+ IRequestExecutorEvents events)
256+
{
257+
- public ValueTask<IRequestExecutor> GetExecutorAsync(CancellationToken ct)
258+
- => resolver.GetRequestExecutorAsync(cancellationToken: ct);
259+
+ public ValueTask<IRequestExecutor> GetExecutorAsync(CancellationToken ct)
260+
+ => executors.GetExecutorAsync(cancellationToken: ct);
261+
262+
- public void EvictDefault() => resolver.EvictRequestExecutor();
263+
+ public void EvictDefault() => executors.EvictExecutor();
264+
265+
- public IDisposable Subscribe(IObserver<RequestExecutorEvent> observer)
266+
- => resolver.Events.Subscribe(observer);
267+
+ public IDisposable Subscribe(IObserver<RequestExecutorEvent> observer)
268+
+ => events.Subscribe(observer);
269+
}
270+
```
271+
272+
The `IServiceProvider.GetRequestExecutorAsync(...)` extension method has been kept as a convenience and now resolves `IRequestExecutorProvider` from the container internally, so call sites such as `services.GetRequestExecutorAsync()` continue to compile unchanged.
273+
274+
The legacy `RequestExecutorEvicted` event (already marked obsolete in v15) has been removed; subscribe to `IRequestExecutorEvents` and filter on `RequestExecutorEventType.Evicted` instead.
275+
276+
## RequestExecutorProxy
277+
278+
`RequestExecutorProxy` still exists and serves the same purpose, giving you a long-lived handle to the executor for a particular schema that is hot-swapped automatically when the schema is rebuilt. Two things have changed:
279+
280+
**Constructor signature.** The proxy no longer takes an `IRequestExecutorResolver`; it now takes the new provider and events abstractions explicitly:
281+
282+
```diff
283+
-var proxy = new RequestExecutorProxy(resolver, "Schema");
284+
+var proxy = new RequestExecutorProxy(executorProvider, executorEvents, "Schema");
285+
```
286+
287+
**The proxy now implements `IRequestExecutor`.** You can pass a `RequestExecutorProxy` directly anywhere an `IRequestExecutor` is expected, without first calling `GetRequestExecutorAsync()`. `ExecuteAsync` and `ExecuteBatchAsync` resolve the current executor internally.
288+
289+
The CLR events `ExecutorUpdated` and `ExecutorEvicted` have been removed. If you need to react to swaps, derive from `RequestExecutorProxy` and override `OnConfigureRequestExecutor(newExecutor, oldExecutor)` (runs under the proxy's lock, before `CurrentExecutor` is replaced) or `OnAfterRequestExecutorSwapped(newExecutor, oldExecutor)` (runs after the swap, outside the lock).
290+
291+
The separate `AutoUpdateRequestExecutorProxy` helper has been removed; the base `RequestExecutorProxy` now subscribes to executor events on construction and updates `CurrentExecutor` automatically.
292+
239293
## Schema.DefaultName moved to ISchemaDefinition.DefaultName
240294

241295
The `Schema.DefaultName` constant is no longer available in v16.

0 commit comments

Comments
 (0)