public async Task <IDictionary <string, object> > ExecuteGroupedFieldSetAsync(
            IExecutorContext context,
            IReadOnlyDictionary <string, List <GraphQLFieldSelection> > groupedFieldSet,
            ObjectType objectType,
            object objectValue,
            NodePath path)
        {
            var tasks = new Dictionary <string, Task <object> >();

            foreach (var fieldGroup in groupedFieldSet)
            {
                var executionTask = FieldGroups.ExecuteFieldGroupAsync(
                    context,
                    objectType,
                    objectValue,
                    //todo: following is dirty
                    new KeyValuePair <string, IReadOnlyCollection <GraphQLFieldSelection> >(fieldGroup.Key,
                                                                                            fieldGroup.Value),
                    path.Fork());

                tasks.Add(fieldGroup.Key, executionTask);
            }

            await Task.WhenAll(tasks.Values).ConfigureAwait(false);

            return(tasks.ToDictionary(kv => kv.Key, kv => kv.Value.Result));
        }
示例#2
0
        public async Task <IDictionary <string, object> > ExecuteGroupedFieldSetAsync(
            IExecutorContext context,
            IReadOnlyDictionary <string, List <GraphQLFieldSelection> > groupedFieldSet,
            ObjectType objectType, object objectValue,
            NodePath path)
        {
            var responseMap = new Dictionary <string, object>();

            foreach (var fieldGroup in groupedFieldSet)
            {
                var responseKey = fieldGroup.Key;

                try
                {
                    var result = await FieldGroups.ExecuteFieldGroupAsync(
                        context,
                        objectType,
                        objectValue,
                        new KeyValuePair <string, IReadOnlyCollection <GraphQLFieldSelection> >(fieldGroup.Key, fieldGroup.Value),
                        path.Fork()).ConfigureAwait(false);

                    responseMap[responseKey] = result;
                }
                catch (QueryExecutionException e)
                {
                    responseMap[responseKey] = null;
                    context.AddError(e);
                }
            }

            return(responseMap);
        }