Subscriptions

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.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy