mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +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;
|
||||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||||
|
|
||||||
@@ -10,10 +13,15 @@ namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
|||||||
{
|
{
|
||||||
// ToDo: Cache clan info!
|
// ToDo: Cache clan info!
|
||||||
// https://hotchocolate.io/docs/dataloaders
|
// https://hotchocolate.io/docs/dataloaders
|
||||||
descriptor.Field("clanInfo")
|
descriptor.Field("clanInfo")
|
||||||
.Resolver(c => c.Service<IWargamingApiClient>()
|
.Resolver(c =>
|
||||||
.GetClanInfo(c.Parent<ClanAccountInfo>().ClanId.Value));
|
{
|
||||||
|
var warGamingClient = c.Service<IWargamingApiClient>();
|
||||||
}
|
var clanDataLoader = c.CacheDataLoader<long, ClanInfo>(
|
||||||
|
"clanInfoById",
|
||||||
|
clanId => warGamingClient.GetClanInfo(clanId));
|
||||||
|
return clanDataLoader.LoadAsync(c.Parent<ClanAccountInfo>().ClanId.Value);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,9 @@ namespace WotBlitzStatistics.GraphQl
|
|||||||
services.AddSingleton<IWargamingApiSettings>(wgApiConfig);
|
services.AddSingleton<IWargamingApiSettings>(wgApiConfig);
|
||||||
services.AddHttpClient<IWargamingApiClient, WargamingApiClient>();
|
services.AddHttpClient<IWargamingApiClient, WargamingApiClient>();
|
||||||
|
|
||||||
|
// this enables you to use DataLoader in your resolvers.
|
||||||
|
services.AddDataLoaderRegistry();
|
||||||
|
|
||||||
// Add GraphQL Services
|
// Add GraphQL Services
|
||||||
services.AddGraphQL(sp => SchemaBuilder.New()
|
services.AddGraphQL(sp => SchemaBuilder.New()
|
||||||
.AddServices(sp)
|
.AddServices(sp)
|
||||||
|
|||||||
@@ -5,10 +5,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="HotChocolate.AspNetCore" Version="10.3.5" />
|
<PackageReference Include="HotChocolate.AspNetCore" Version="10.3.6" />
|
||||||
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="10.3.5" />
|
<PackageReference Include="HotChocolate.AspNetCore.Abstractions" Version="10.3.6" />
|
||||||
<PackageReference Include="HotChocolate.AspNetCore.Playground" Version="10.3.5" />
|
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="10.3.6" />
|
||||||
<PackageReference Include="HotChocolate.AspNetCore.Voyager" Version="10.3.5" />
|
<PackageReference Include="HotChocolate.AspNetCore.Playground" Version="10.3.6" />
|
||||||
|
<PackageReference Include="HotChocolate.AspNetCore.Voyager" Version="10.3.6" />
|
||||||
|
<PackageReference Include="HotChocolate.Types.Filters" Version="10.3.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user