public static async Task <ISubscribeResult> CreateSourceEventStreamAsync( IExecutorContext context, GraphQLOperationDefinition subscription, Dictionary <string, object> coercedVariableValues, object initialValue, CancellationToken cancellationToken) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (subscription == null) { throw new ArgumentNullException(nameof(subscription)); } if (coercedVariableValues == null) { throw new ArgumentNullException(nameof(coercedVariableValues)); } cancellationToken.ThrowIfCancellationRequested(); var schema = context.Schema; var subscriptionType = schema.Subscription; var groupedFieldSet = SelectionSets.CollectFields( context.Schema, context.Document, subscriptionType, subscription.SelectionSet, coercedVariableValues ); var fields = groupedFieldSet.Values.First(); var fieldName = fields.First().Name.Value; var fieldSelection = fields.First(); var coercedArgumentValues = Arguments.CoerceArgumentValues( schema, subscriptionType, fieldSelection, coercedVariableValues); var field = schema.GetField(subscriptionType.Name, fieldName); var path = new NodePath(); var resolveContext = new ResolverContext( schema, subscriptionType, initialValue, field, fieldSelection, coercedArgumentValues, path, context); var subscriber = schema.GetSubscriber(subscriptionType.Name, fieldName); if (subscriber == null) { throw new GraphQLError( $"Could not subscribe. Field '{subscriptionType}:{fieldName}' does not have subscriber"); } var subscribeResult = await subscriber(resolveContext, cancellationToken) .ConfigureAwait(false); return(subscribeResult); }