Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,36 @@ We removed the following methods from the `IExecutionDiagnosticEventListener` si

Some other methods also had a change in their signature - simply override them again to fix any compilation issues.

## IOperationMessagePayload exposes raw JSON

The `IOperationMessagePayload` interface, used by `ISocketSessionInterceptor` hooks (`OnConnectAsync`, `OnPingAsync`, `OnPongAsync`), no longer exposes the `As<T>()` deserialization helper. It now provides direct access to the raw `JsonElement?` through a `Payload` property:

```diff
-public interface IOperationMessagePayload
-{
- T? As<T>() where T : class;
-}
+public interface IOperationMessagePayload
+{
+ JsonElement? Payload { get; }
+}
```

If you were calling `.As<T>()` to deserialize the payload, switch to `Payload?.Deserialize<T>()`:

```diff
public override ValueTask<ConnectionStatus> OnConnectAsync(
ISocketSession session,
IOperationMessagePayload connectionInitMessage,
CancellationToken cancellationToken = default)
{
- var payload = connectionInitMessage.As<MyConnectPayload>();
+ var payload = connectionInitMessage.Payload?.Deserialize<MyConnectPayload>();

// ...
}
```

## Experimental @semanticNonNull support removed

Hot Chocolate v15 included experimental support for the `@semanticNonNull` directive, which let you mark fields as semantically non-null while still returning `null` (rather than propagating to the parent) when a resolver errored. We've removed this feature in v16 in favor of the [`onError` proposal](https://github.com/graphql/graphql-spec/pull/1163).
Expand Down
6 changes: 4 additions & 2 deletions website/src/docs/hotchocolate/v16/server/interceptors.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ public override ValueTask<ConnectionStatus> OnConnectAsync(
ISocketSession session, IOperationMessagePayload connectionInitMessage,
CancellationToken cancellationToken)
{
if (connectionInitMessage.As<Dictionary<string, object?>>()
?.TryGetValue("authToken", out var token) == true)
if (connectionInitMessage.Payload is { ValueKind: JsonValueKind.Object } payload
&& payload.TryGetProperty("authToken", out var token)
&& token.ValueKind == JsonValueKind.String)
{
var authToken = token.GetString();
// Validate token ...
}

Expand Down
Loading