Reputation: 3080
I am implementing HotChocolate as part of my ASP.NET API. I'm trying to add subscriptions to the chat portion on my app, however, the documentation on the HotChocolate site is not implemented yet. From what I can tell from other sites/frameworks, I can use the C# IObservable<Chat>
as the return type for the subscription method.
Can anyone give me an example of a query method or point me towards another resource?
public async Task<IObservable<Message>> GetMessages(Guid chatId) {
var messages = ..Get chats;
return messages;
}
However, how does this work from a query standpoint? How do we trigger an event to update this?
Thanks.
Upvotes: 8
Views: 4377
Reputation: 1927
Since the original documentation link became obsolete I am posting this new link that refers to our workshop project.
Chapter 7 shows how to do subscriptions in two variants. https://github.com/ChilliCream/graphql-workshop/blob/master/docs/7-subscriptions.md
I hope that helps.
Upvotes: 6