Exemplo n.º 1
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.º 2
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);
            }
        }
        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
            ValueCompletion.CompleteValue(enqueueNext, resolverContext);
        }
Exemplo n.º 4
0
        private static async Task EndExecuteResolverBatchAsync(
            IEnumerable <ResolverContext> batch,
            Action <ResolverContext> enqueueNext,
            CancellationToken cancellationToken)
        {
            foreach (ResolverContext resolverContext in batch)
            {
                if (resolverContext.Task.Status != TaskStatus.RanToCompletion)
                {
                    await resolverContext.Task.ConfigureAwait(false);
                }

                ValueCompletion.CompleteValue(enqueueNext, resolverContext);

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