private async Task ExecuteOperationAsync(GraphQLOperation op, OutputObjectScope topScope) { var opOutItemSet = op.SelectionSubset.MappedItemSets.FirstOrDefault(fi => fi.ObjectTypeDef == op.OperationTypeDef); var topFields = _requestContext.GetIncludedMappedFields(opOutItemSet); topScope.Init(op.OperationTypeDef, topFields); var parallel = _parallelQuery && op.OperationType == OperationType.Query && topFields.Count > 1; // Note: if we go parallel here, note that the topScope is safe for concurrent thread access; // it is only used to save op result value (SetValue method) var executers = new List <OperationFieldExecuter>(); for (int fieldIndex = 0; fieldIndex < topFields.Count; fieldIndex++) { var opExecuter = new OperationFieldExecuter(_requestContext, topScope, fieldIndex); executers.Add(opExecuter); } _requestContext.Metrics.ExecutionThreadCount = executers.Count; if (parallel) { await ExecuteAllParallel(executers); } else { await ExecuteAllNonParallel(executers); } }
public FieldContext(RequestContext requestContext, OperationFieldExecuter fieldExecuter, MappedSelectionField mappedField, IList <OutputObjectScope> allParentScopes = null) { _requestContext = requestContext; _executer = fieldExecuter; MappedField = mappedField; FieldDef = MappedField.Resolver.Field; TypeDef = FieldDef.TypeRef.TypeDef; AllParentScopes = allParentScopes ?? OutputObjectScope.EmptyList; if (MappedField.Field.SelectionSubset != null) { AllResultScopes = new List <OutputObjectScope>(); } }