Subscriptions are supported through the use of IObservable<T>
. You will need a server that supports a Subscription protocol. The GraphQL Server project provides a .NET Core server that implements the Apollo GraphQL subscription protocol. See the GraphQL Server project samples.
Instead of using the query
or mutation
keyword you are required to use subscription
. Similar to a query
and mutation
, you can omit the Operation
name if there is only a single operation in the request.
subscription MessageAdded {
messageAdded {
from {
id
displayName
}
content
sentAt
}
}
public class ChatSubscriptions : ObjectGraphType
{
private readonly IChat _chat;
public ChatSubscriptions(IChat chat)
{
_chat = chat;
Field<MessageType, Message>("messageAdded")
.ResolveStream(ResolveStream);
}
private IObservable<Message> ResolveStream(IResolveFieldContext context)
{
return _chat.Messages();
}
}
See this full schema here.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4