Skip to content

Commit

Permalink
Fix DataLoader concurrent issues
Browse files Browse the repository at this point in the history
Fixes #9651
  • Loading branch information
sebastienros authored Jun 24, 2021
1 parent f3bf8d5 commit ea0d3a1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ namespace OrchardCore.Apis.GraphQL
{
public static class DataLoaderExtensions
{
public static Task<T[]> LoadAsync<TKey, T>(this IDataLoader<TKey, T> dataLoader, IEnumerable<TKey> keys)
public static async Task<T[]> LoadAsync<TKey, T>(this IDataLoader<TKey, T> dataLoader, IEnumerable<TKey> keys)
{
var tasks = new List<Task<T>>();
var items = new List<T>();

foreach (var key in keys)
{
tasks.Add(dataLoader.LoadAsync(key));
items.Add(await dataLoader.LoadAsync(key));
}

return Task.WhenAll(tasks);
return items.ToArray();
}

public static Task<T[]> LoadAsync<TKey, T>(this IDataLoader<TKey, T> dataLoader, params TKey[] keys)
Expand Down

0 comments on commit ea0d3a1

Please sign in to comment.