mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-24 03:40:07 +02:00
Some Data loader stuff
This commit is contained in:
1 parent
d643c323b3
commit
83628d21bd
5 files changed
+61
-14
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using GreenDonut;
|
||||
using HotChocolate.Resolvers;
|
||||
using HotChocolate.Types;
|
||||
using WotBlitzStatistics.GraphQl.Resolvers;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
@@ -11,17 +12,7 @@ namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||
{
|
||||
protected override void Configure(IObjectTypeDescriptor<ClanAccountInfo> descriptor)
|
||||
{
|
||||
// ToDo: Cache clan info!
|
||||
// https://hotchocolate.io/docs/dataloaders
|
||||
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);
|
||||
});
|
||||
descriptor.Include<ClanInfoResolver>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user