示例#1
0
        public async Task <IQueryResult> ExecuteAsync(
            IOperationContext operationContext,
            IImmutableDictionary <string, object?> scopedContext)
        {
            if (operationContext is null)
            {
                throw new ArgumentNullException(nameof(operationContext));
            }

            if (scopedContext is null)
            {
                throw new ArgumentNullException(nameof(scopedContext));
            }

            ISelectionSet rootSelections =
                operationContext.Operation.GetRootSelectionSet();

            ResultMap resultMap = rootSelections.EnqueueResolverTasks(
                operationContext, Path.Root, scopedContext,
                operationContext.RootValue);

            await ExecuteTasksAsync(operationContext).ConfigureAwait(false);

            return(operationContext
                   .TrySetNext()
                   .SetData(resultMap)
                   .BuildResult());
        }
示例#2
0
    /// <inheritdoc/>
    public async Task <IQueryResult?> ExecuteAsync(IOperationContext operationContext)
    {
        _task ??= new StreamExecutionTask(operationContext, this);
        _task.Reset();

        operationContext.QueryPlan = operationContext.QueryPlan.GetStreamPlan(Selection.Id);
        operationContext.Scheduler.Register(_task);
        await operationContext.Scheduler.ExecuteAsync().ConfigureAwait(false);

        if (_task.ChildTask is null)
        {
            return(null);
        }

        operationContext.Scheduler.DeferredWork.Register(this);

        IQueryResult result = operationContext
                              .TrySetNext(true)
                              .SetLabel(Label)
                              .SetPath(Path.Append(Index))
                              .SetData((ResultMap)_task.ChildTask.ResultMap[0].Value !)
                              .BuildResult();

        _task.ChildTask.CompleteUnsafe();

        return(result);
    }
        private static async Task <IQueryResult> ExecuteSelectionsAsync(
            IOperationContext operationContext,
            IReadOnlyList <ISelection> selections,
            ResultMap resultMap)
        {
            var responseIndex = 0;
            ImmutableDictionary <string, object?> scopedContext =
                ImmutableDictionary <string, object?> .Empty;

            for (var i = 0; i < selections.Count; i++)
            {
                ISelection selection = selections[i];
                if (selection.IsIncluded(operationContext.Variables))
                {
                    operationContext.Execution.TaskBacklog.Register(
                        new ResolverTaskDefinition(
                            operationContext,
                            selection,
                            responseIndex++,
                            resultMap,
                            operationContext.RootValue,
                            Path.New(selection.ResponseName),
                            scopedContext));

                    await ExecuteTasksAsync(operationContext).ConfigureAwait(false);
                }
            }

            return(operationContext
                   .TrySetNext()
                   .SetData(resultMap)
                   .BuildResult());
        }
        /// <inheritdoc/>
        public async Task <IQueryResult> ExecuteAsync(IOperationContext operationContext)
        {
            ResultMap resultMap = Fragment.SelectionSet.EnqueueResolverTasks(
                operationContext,
                Path,
                ScopedContextData,
                Value);

            await ResolverExecutionHelper
            .ExecuteTasksAsync(operationContext)
            .ConfigureAwait(false);

            return(operationContext
                   .TrySetNext(true)
                   .SetLabel(Label)
                   .SetPath(Path)
                   .SetData(resultMap)
                   .BuildResult());
        }
示例#5
0
        /// <inheritdoc/>
        public async Task <IQueryResult?> ExecuteAsync(IOperationContext operationContext)
        {
            operationContext.QueryPlan = operationContext.QueryPlan.GetDeferredPlan(Fragment.Id);

            ResultMap resultMap = EnqueueResolverTasks(
                operationContext,
                Fragment.SelectionSet,
                Parent,
                Path,
                ScopedContextData);

            await operationContext.Scheduler.ExecuteAsync().ConfigureAwait(false);

            return(operationContext
                   .TrySetNext(true)
                   .SetLabel(Label)
                   .SetPath(Path)
                   .SetData(resultMap)
                   .BuildResult());
        }
示例#6
0
        private static async Task <IQueryResult> ExecuteInternalAsync(
            IOperationContext operationContext,
            IImmutableDictionary <string, object?> scopedContext)
        {
            ISelectionSet rootSelections =
                operationContext.Operation.GetRootSelectionSet();

            ResultMap resultMap = EnqueueResolverTasks(
                operationContext,
                rootSelections,
                operationContext.RootValue,
                Path.Root,
                scopedContext);

            await operationContext.Scheduler.ExecuteAsync().ConfigureAwait(false);

            return(operationContext
                   .TrySetNext()
                   .SetData(resultMap)
                   .BuildResult());
        }