graphql-workshop
graphql-workshop copied to clipboard
Subscription is closed with the error "Value cannot be null. (Parameter 'payload')" when need to return null
EROR always when need return null.
Calling await sender.SendAsync($"CaseInProgress_{runId}", (int?)null);
public class CaseInProgressChangedPayload
{
public int? CaseInProgress { get; set; }
}
[Subscribe]
[Topic("CaseInProgress_{runId}")]
public CaseInProgressChangedPayload OnCaseInProgressChanged(int runId, [EventMessage] int? caseInProgress)
{
return new CaseInProgressChangedPayload
{
CaseInProgress = caseInProgress
};
}
OR
[Subscribe]
[Topic("CaseInProgress_{runId}")]
public int? OnCaseInProgressChanged(int runId, [EventMessage] int? caseInProgress) => caseInProgress;
OR
[Subscribe]
[Topic("CaseInProgress_{runId}")]
public int? OnCaseInProgressChanged(int runId, [EventMessage] int? caseInProgress)
{
return caseInProgress;
}
Full log: {"type":"connection_ack"} { "id": "91f6db40-c442-45d3-b0d3-bf792ed379ee", "type": "error", "payload": [ { "message": "Value cannot be null. (Parameter 'payload')", "extensions": { "message": "Value cannot be null. (Parameter 'payload')", "stackTrace": " at HotChocolate.Execution.Instrumentation.SubscriptionEventContext..ctor(ISubscription subscription, Object payload)\r\n at HotChocolate.Execution.Processing.SubscriptionExecutor.Subscription.OnEvent(Object payload)\r\n at HotChocolate.Execution.Processing.SubscriptionExecutor.SubscriptionEnumerator.MoveNextAsync()\r\n at HotChocolate.AspNetCore.Subscriptions.OperationSession.SendResultsAsync(GraphQLRequest request, CancellationToken cancellationToken)\r\n at HotChocolate.AspNetCore.Subscriptions.OperationSession.SendResultsAsync(GraphQLRequest request, CancellationToken cancellationToken)\r\n at HotChocolate.AspNetCore.Subscriptions.OperationSession.SendResultsAsync(GraphQLRequest request, CancellationToken cancellationToken)" } } ] }
Following as I've just hit the same error. In my case, I return a custom record rather than an int?. The record itself is not null, but one of its properties is.
Looks like this is a duplicate of https://github.com/ChilliCream/graphql-platform/issues/6720