diff --git a/website-next/content/docs/hotchocolate/migrating/migrate-from-15-to-16.md b/website-next/content/docs/hotchocolate/migrating/migrate-from-15-to-16.md index ac2b7301a67..8a4231a5216 100644 --- a/website-next/content/docs/hotchocolate/migrating/migrate-from-15-to-16.md +++ b/website-next/content/docs/hotchocolate/migrating/migrate-from-15-to-16.md @@ -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()` deserialization helper. It now provides direct access to the raw `JsonElement?` through a `Payload` property: + +```diff +-public interface IOperationMessagePayload +-{ +- T? As() where T : class; +-} ++public interface IOperationMessagePayload ++{ ++ JsonElement? Payload { get; } ++} +``` + +If you were calling `.As()` to deserialize the payload, switch to `Payload?.Deserialize()`: + +```diff +public override ValueTask OnConnectAsync( + ISocketSession session, + IOperationMessagePayload connectionInitMessage, + CancellationToken cancellationToken = default) +{ +- var payload = connectionInitMessage.As(); ++ var payload = connectionInitMessage.Payload?.Deserialize(); + + // ... +} +``` + ## 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). diff --git a/website/src/docs/hotchocolate/v16/server/interceptors.md b/website/src/docs/hotchocolate/v16/server/interceptors.md index 682ba716410..081a0bc5d5f 100644 --- a/website/src/docs/hotchocolate/v16/server/interceptors.md +++ b/website/src/docs/hotchocolate/v16/server/interceptors.md @@ -176,9 +176,11 @@ public override ValueTask OnConnectAsync( ISocketSession session, IOperationMessagePayload connectionInitMessage, CancellationToken cancellationToken) { - if (connectionInitMessage.As>() - ?.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 ... }