private async Task <ExpandoObject> ProcessSubscription( GraphQLSubscriptionType type, IFieldCollector fieldCollector, FieldScope scope) { var fields = fieldCollector.CollectFields(type, this.Operation.SelectionSet); var field = fields.Single(); //only single subscription field allowed var result = new ExpandoObject(); var resultDictionary = (IDictionary <string, object>)result; await this.RegisterSubscription( field.Value.Single(), type, this.ast, scope); resultDictionary.Add("subscriptionId", this.subscriptionId.Value); resultDictionary.Add("clientId", this.clientId); var returnObject = new ExpandoObject(); var returnObjectDictionary = (IDictionary <string, object>)returnObject; returnObjectDictionary.Add("data", result); if (scope.Errors.Any()) { returnObjectDictionary.Add("errors", scope.Errors); } return(returnObject); }
public FieldScope( ITypeTranslator typeTranslator, IValueResolver valueResolver, IFieldCollector fieldCollector, GraphQLObjectType type, object parent) { this.type = type; this.parent = parent; this.arguments = new List <GraphQLArgument>(); this.fieldCollector = fieldCollector; this.typeTranslator = typeTranslator; this.valueResolver = valueResolver; }