mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +02:00
chore: added some metadata to response to sinplify clan resolver
This commit is contained in:
1 parent
6ed4738197
commit
53fb441b93
5 files changed
+10
-46
No files matched your search
@@ -168,5 +168,9 @@ namespace WotBlitzStatisticsPro.Common.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ClanInfoResponse? ClanInfo { get; set; }
|
public ClanInfoResponse? ClanInfo { get; set; }
|
||||||
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// Account Region and request language
|
||||||
|
/// </summary>
|
||||||
|
public RealmAndLanguage RegionAndLanguage { get; set; } = new(RealmType.Eu, RequestLanguage.En);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using HotChocolate.Language;
|
|
||||||
using WotBlitzStatisticsPro.Common.Model;
|
|
||||||
|
|
||||||
namespace WotBlitzStatisticsPro.GraphQl.Helpers
|
|
||||||
{
|
|
||||||
public static class ParametersParser
|
|
||||||
{
|
|
||||||
private const RealmType DefaultRealm = RealmType.Ru;
|
|
||||||
private const RequestLanguage DefaultRequestLanguage = RequestLanguage.En;
|
|
||||||
|
|
||||||
public static RealmAndLanguage ParseOperation(this OperationDefinitionNode operationDefinition)
|
|
||||||
{
|
|
||||||
var realm = DefaultRealm;
|
|
||||||
var language = DefaultRequestLanguage;
|
|
||||||
var selections = operationDefinition?.SelectionSet.Selections.ToArray();
|
|
||||||
if (selections != null && selections.Length == 1)
|
|
||||||
{
|
|
||||||
var node = selections[0] as FieldNode;
|
|
||||||
if (node?.Arguments != null)
|
|
||||||
{
|
|
||||||
foreach (var argument in node.Arguments.Where(a => a != null))
|
|
||||||
{
|
|
||||||
switch (argument.Name.Value)
|
|
||||||
{
|
|
||||||
case "realmType" when argument?.Value?.Value != null:
|
|
||||||
realm = (RealmType)Enum.Parse(typeof(RealmType), argument.Value.Value.ToString() ?? "Ru", true);
|
|
||||||
break;
|
|
||||||
case "requestLanguage" when argument?.Value?.Value != null:
|
|
||||||
language = (RequestLanguage)Enum.Parse(typeof(RequestLanguage), argument.Value.Value.ToString() ?? "En", true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new (realm, language);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using HotChocolate.Types;
|
using HotChocolate.Types;
|
||||||
using WotBlitzStatisticsPro.Common.Model;
|
using WotBlitzStatisticsPro.Common.Model;
|
||||||
using WotBlitzStatisticsPro.GraphQl.Helpers;
|
|
||||||
using WotBlitzStatisticsPro.Logic;
|
using WotBlitzStatisticsPro.Logic;
|
||||||
|
|
||||||
namespace WotBlitzStatisticsPro.GraphQl.Resolvers
|
namespace WotBlitzStatisticsPro.GraphQl.Resolvers
|
||||||
@@ -11,8 +10,7 @@ namespace WotBlitzStatisticsPro.GraphQl.Resolvers
|
|||||||
protected override void Configure(IObjectTypeDescriptor<AccountInfoResponse> descriptor)
|
protected override void Configure(IObjectTypeDescriptor<AccountInfoResponse> descriptor)
|
||||||
{
|
{
|
||||||
descriptor.Field(t => t.ClanInfo)
|
descriptor.Field(t => t.ClanInfo)
|
||||||
.Resolver(ctx => ctx.Service<IWargamingClans>().GelClanInfoByAccount(ctx.Parent<AccountInfoResponse>().AccountId, ctx.Operation.ParseOperation()));
|
.Resolver(ctx => ctx.Service<IWargamingClans>().GelClanInfoByAccount(ctx.Parent<AccountInfoResponse>().AccountId, ctx.Parent<AccountInfoResponse>().RegionAndLanguage));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="DataLoaders\" />
|
<Folder Include="DataLoaders\" />
|
||||||
|
<Folder Include="Helpers\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
@@ -46,6 +46,9 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
|||||||
contextData.Response = _mapper.Map<AccountInfo, AccountInfoResponse>(contextData.AccountInfo);
|
contextData.Response = _mapper.Map<AccountInfo, AccountInfoResponse>(contextData.AccountInfo);
|
||||||
contextData.Response = _mapper.Map(contextData.AccountInfoHistory, contextData.Response);
|
contextData.Response = _mapper.Map(contextData.AccountInfoHistory, contextData.Response);
|
||||||
|
|
||||||
|
contextData.Response.RegionAndLanguage =
|
||||||
|
new RealmAndLanguage(context.Request.RealmType, context.Request.RequestLanguage);
|
||||||
|
|
||||||
var tankIds = contextData.Tanks.Select(t => t.TankId).ToArray();
|
var tankIds = contextData.Tanks.Select(t => t.TankId).ToArray();
|
||||||
var vehicles = await _dictionariesDataAccessor.GetVehicles(tankIds);
|
var vehicles = await _dictionariesDataAccessor.GetVehicles(tankIds);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user