I have a graphQL api I am trying to query .
I added a server side function :
public class Subscription1
{
[SubscribeAndResolve]
[Topic]
[UseDbContext(typeof(ApplicationDbContext))]
public IQueryable<Alert> OnAlertAdded([Service] ApplicationDbContext context, int clientId)
{
return context.AlertClients
.Where(ac => ac.ClientId == clientId)
.Select(ac => ac.Alert)
.AsQueryable();
}
}
and I am using postman to get the data :
subscription OnAlertAdded {
onAlertAdded(clientId: 1) {
id
name
}
}
the problem is that the function returns all the alerts that belong to client id =1 but then then I see in postman logs WebSocket disconencted error 1006 and Operation completed .
I subscriptions that once called should query in a loop and never hung and everytime the server adds new alert the clients should be notified – at least this is what I was trying to achieve .
Is there any way I can get my code to work this way ? (listen constanatly and be notified by server changes )
Thanks so much!