I have an ASP .NET Core GraphQL API using HotChocolate. It is possible to start a long-running operation using a mutation, in this case extracting a file. I am using subscriptions to notify the user when the process is finished. But if an exception occours, how to I throw it in the subscription?
My subscription:
[Subscribe]
public FilePayload FileExtracted([EventMessage] FilePayload file)
{
return file;
}
How I am sending the event to the subscription from the service layer:
await _eventSender.SendAsync(nameof(FileSubscriptions.FileExtracted), zipFilePayload,
cancellationToken);
When I try to pass a second parameter of type Exception to the subscription, it just instantly terminates with an empty "errors" object. What is the correct way of doing this?