Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using GraphQLSampleApp.DataAccess.Entity;
using HotChocolate;
using HotChocolate.Execution;
using HotChocolate.Subscriptions;
using HotChocolate.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace GraphQLSampleApp.DataAccess
{
public class Subscription
{
[SubscribeAndResolve]
public async ValueTask<ISourceStream<Department>> OnDepartmentCreate([Service] ITopicEventReceiver eventReceiver,
CancellationToken cancellationToken)
{
return await eventReceiver.SubscribeAsync<string, Department>("DepartmentCreated", cancellationToken);
}
[SubscribeAndResolve]
public async ValueTask<ISourceStream<Employee>> OnEmployeeGet([Service] ITopicEventReceiver eventReceiver,
CancellationToken cancellationToken)
{
return await eventReceiver.SubscribeAsync<string, Employee>("ReturnedEmployee", cancellationToken);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment