private async Task ExecuteResolverSeriallyAsync(
            IExecutionContext executionContext,
            ResolverTask resolverTask,
            Action <ResolverTask> enqueueTask,
            BatchOperationHandler batchOperationHandler,
            CancellationToken cancellationToken)
        {
            resolverTask.Task = ExecuteResolverAsync(
                resolverTask,
                executionContext.ErrorHandler,
                cancellationToken);
            await CompleteBatchOperationsAsync(
                new[] { resolverTask.Task },
                batchOperationHandler,
                cancellationToken)
            .ConfigureAwait(false);

            resolverTask.ResolverResult = await resolverTask.Task
                                          .ConfigureAwait(false);

            // serialize and integrate result into final query result
            var completionContext = new CompleteValueContext(
                executionContext.Services.GetTypeConversion(),
                executionContext.FieldHelper, enqueueTask);

            completionContext.CompleteValue(resolverTask);
        }
Exemplo n.º 2
0
        public static void CompleteValue(
            Action <ResolverContext> enqueueNext,
            ResolverContext resolverContext)
        {
            CompleteValueContext completionContext = _completionContext.Value;

            completionContext.Clear();

            completionContext.EnqueueNext     = enqueueNext;
            completionContext.ResolverContext = resolverContext;

            CompleteValue(
                completionContext,
                resolverContext.Field.Type,
                resolverContext.Result);

            if (completionContext.IsViolatingNonNullType)
            {
                resolverContext.PropagateNonNullViolation.Invoke();
            }
            else
            {
                resolverContext.SetCompletedValue(completionContext.Value);
            }

            completionContext.Clear();
        }
Exemplo n.º 3
0
        private static async Task ExecuteResolverSeriallyAsync(
            ResolverContext resolverContext,
            Action <ResolverContext> enqueueNext,
            BatchOperationHandler batchOperationHandler,
            IErrorHandler errorHandler,
            CancellationToken cancellationToken)
        {
            resolverContext.Task = ExecuteResolverAsync(
                resolverContext,
                errorHandler);

            if (batchOperationHandler != null)
            {
                await CompleteBatchOperationsAsync(
                    new[] { resolverContext },
                    batchOperationHandler,
                    cancellationToken)
                .ConfigureAwait(false);
            }

            await resolverContext.Task.ConfigureAwait(false);

            // serialize and integrate result into final query result
            var completionContext = new CompleteValueContext(enqueueNext);

            completionContext.CompleteValue(resolverContext);
        }
Exemplo n.º 4
0
        public static void CompleteValue(
            this CompleteValueContext context,
            ResolverTask resolverTask)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.ResolverTask = resolverTask;

            ValueCompletion.CompleteValue(
                context,
                resolverTask.FieldType,
                resolverTask.ResolverResult);

            if (context.IsViolatingNonNullType)
            {
                resolverTask.PropagateNonNullViolation();
            }
            else
            {
                resolverTask.SetResult(context.Value);
            }
        }
Exemplo n.º 5
0
        public static void CompleteValue(
            this CompleteValueContext completionContext,
            ResolverContext resolverContext)
        {
            if (completionContext == null)
            {
                throw new ArgumentNullException(nameof(completionContext));
            }

            completionContext.ResolverContext = resolverContext;

            ValueCompletion.CompleteValue(
                completionContext,
                resolverContext.Field.Type,
                resolverContext.Result);

            if (completionContext.IsViolatingNonNullType)
            {
                resolverContext.PropagateNonNullViolation.Invoke();
            }
            else
            {
                resolverContext.SetCompletedValue(completionContext.Value);
            }
        }
Exemplo n.º 6
0
        private static async Task EndExecuteResolverBatchAsync(
            IExecutionContext executionContext,
            IEnumerable <ResolverTask> currentBatch,
            Action <ResolverTask> enqueueTask,
            CancellationToken cancellationToken)
        {
            var completionContext = new CompleteValueContext(
                executionContext.Services.GetTypeConversion(),
                executionContext.FieldHelper, enqueueTask);

            foreach (ResolverTask resolverTask in currentBatch)
            {
                resolverTask.ResolverResult = await resolverTask.Task
                                              .ConfigureAwait(false);

                completionContext.CompleteValue(resolverTask);

                cancellationToken.ThrowIfCancellationRequested();
            }
        }
Exemplo n.º 7
0
        private static async Task EndExecuteResolverBatchAsync(
            IEnumerable <ResolverContext> batch,
            Action <ResolverContext> enqueueNext,
            CancellationToken cancellationToken)
        {
            var completionContext = new CompleteValueContext(enqueueNext);

            foreach (ResolverContext resolverContext in batch)
            {
                if (resolverContext.Task.Status != TaskStatus.RanToCompletion)
                {
                    await resolverContext.Task.ConfigureAwait(false);
                }

                completionContext.CompleteValue(resolverContext);

                if (!resolverContext.IsRoot)
                {
                    ResolverContext.Return(resolverContext);
                }
            }
        }