public async Task ExecuteOperationFieldAsync() { try { if (_mappedOpField.Field.OnExecuting(_requestContext, out var args) && args.Skip) { Result = DBNull.Value; // it's a signal to skip value in output return; } var opFieldContext = new FieldContext(_requestContext, this, _mappedOpField); opFieldContext.SetCurrentParentScope(_parentScope); // We do not save result in parent top-level context: we maybe executing in parallel with other top-level fields; // we need synchronization(lock), and also op fields might finish out of order. So we save result in a field, and // RequestHandler will save all results from executers in proper order. //_parentScope.SetValue(_mappedOpField.Field.Key, opOutValue); -- do not do this this.Result = await InvokeResolverAsync(opFieldContext); // for fields returning objects, save for further processing of results if (opFieldContext.MappedField.Field.SelectionSubset != null) { _executedObjectFieldContexts.Add(opFieldContext); } // process object field results until no more while (_executedObjectFieldContexts.Count > 0) { if (_requestContext.CancellationToken.IsCancellationRequested) { opFieldContext.ThrowRequestCancelled(); } // save current list, create new one in the field var oldFieldContexts = _executedObjectFieldContexts; _executedObjectFieldContexts = new List <FieldContext>(); foreach (var fldCtx in oldFieldContexts) { await ExecuteFieldSelectionSubsetAsync(fldCtx); } }//while } finally { // notify resolvers about end request if (_resolverInstances.Count > 0) { foreach (var resObj in _resolverInstances) { (resObj as IResolverClass)?.EndRequest(_requestContext); } } } }
public async Task ExecuteOperationFieldAsync() { try { var opFieldContext = new FieldContext(_requestContext, this, _operationField, _fieldIndex); opFieldContext.CurrentScope = _parentScope; var result = await InvokeResolverAsync(opFieldContext); var opOutValue = opFieldContext.ConvertToOuputValue(result); _parentScope.SetValue(_fieldIndex, opOutValue); // for fields returning objects, save for further processing of results if (opFieldContext.Flags.IsSet(FieldFlags.ReturnsComplexType)) { _executedObjectFieldContexts.Add(opFieldContext); } // process object field results until no more while (_executedObjectFieldContexts.Count > 0) { if (_requestContext.CancellationToken.IsCancellationRequested) { opFieldContext.ThrowRequestCancelled(); } // save current list, create new one in the field var oldFieldContexts = _executedObjectFieldContexts; _executedObjectFieldContexts = new List <FieldContext>(); foreach (var fldCtx in oldFieldContexts) { await ExecuteFieldSelectionSubsetAsync(fldCtx); } }//while } finally { // notify resolvers about end request if (_resolverInstances.Count > 0) { foreach (var resObj in _resolverInstances) { (resObj as IResolverClass)?.EndRequest(_requestContext); } } } }