mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 11:20:05 +02:00
Clan info with caching
This commit is contained in:
1 parent
089c6329ee
commit
d643c323b3
3 files changed
+23
-10
No files matched your search
@@ -1,4 +1,7 @@
|
||||
using HotChocolate.Types;
|
||||
using System.Threading;
|
||||
using GreenDonut;
|
||||
using HotChocolate.Resolvers;
|
||||
using HotChocolate.Types;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
@@ -10,10 +13,15 @@ namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||
{
|
||||
// ToDo: Cache clan info!
|
||||
// https://hotchocolate.io/docs/dataloaders
|
||||
descriptor.Field("clanInfo")
|
||||
.Resolver(c => c.Service<IWargamingApiClient>()
|
||||
.GetClanInfo(c.Parent<ClanAccountInfo>().ClanId.Value));
|
||||
|
||||
}
|
||||
descriptor.Field("clanInfo")
|
||||
.Resolver(c =>
|
||||
{
|
||||
var warGamingClient = c.Service<IWargamingApiClient>();
|
||||
var clanDataLoader = c.CacheDataLoader<long, ClanInfo>(
|
||||
"clanInfoById",
|
||||
clanId => warGamingClient.GetClanInfo(clanId));
|
||||
return clanDataLoader.LoadAsync(c.Parent<ClanAccountInfo>().ClanId.Value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user