feat: Strawberry Shake first query

This commit is contained in:
Mikhail Shabanov committed 2021-05-14 11:37:45 +02:00
1 parent 235a717f51
commit 798a9d0e43
7 files changed
+1095 -9

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
"extensions": {
"strawberryShake": {
"name": "WotBlitzStatisticsProClient",
"namespace": "WotBlitzStatisticsPro.Blazor",
"namespace": "WotBlitzStatisticsPro.Blazor.GraphQl",
"url": "https://localhost:5001/graphql/",
"dependencyInjection": true,
"strictSchemaValidation": true,
@@ -0,0 +1,19 @@
query findAccounts(
$accountNick: String!,
$realmType: RealmType!,
$language: RequestLanguage!) {
findAccounts(
accountNick: $accountNick,
realmType: $realmType,
language: $language) {
accountsCount
accounts {
accountId
nickname
clanTag
lastBattle
battlesCount
winRate
}
}
}
@@ -4,6 +4,7 @@ using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Radzen;
using WotBlitzStatisticsPro.Blazor.GraphQl;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
@@ -20,6 +21,9 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
[Inject]
public IStringLocalizer<App> Localizer { get; set; }
[Inject]
public WotBlitzStatisticsProClient WotBlitzStatisticsProClient { get; set; }
[Parameter]
public DialogType DialogType { get; set; }
@@ -39,15 +43,23 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
FilteredList.Clear();
await InvokeAsync(StateHasChanged);
// ToDo: Call GraphQL Backend CurrentRealmType + value
await Task.Delay(1000);
for (int i = 0; i < 15; i++)
// ToDo: Add busy cursor
// ToDo: Move this call to a service
var accounts =
await WotBlitzStatisticsProClient.FindAccounts.ExecuteAsync(value, RealmType.Ru, RequestLanguage.En);
if (accounts?.Data?.FindAccounts?.Accounts != null)
{
FilteredList.Add(new SearchItem(i, $"Item number {i}"));
foreach (var account in accounts.Data.FindAccounts.Accounts)
{
FilteredList.Add(new SearchItem(account.AccountId, $"{account.Nickname} [{account.ClanTag}] | {account.WinRate}%"));
}
await InvokeAsync(StateHasChanged);
}
await InvokeAsync(StateHasChanged);
}
public async Task OnOkButtonClick()
+7
View File
@@ -30,6 +30,13 @@ namespace WotBlitzStatisticsPro.Blazor
builder.Services.AddSingleton<NavigationMessagesInterceptor>();
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
// ToDo: Find out URL
// StrawberryShake GraphQL Client
builder.Services
.AddWotBlitzStatisticsProClient()
.ConfigureHttpClient(client => client.BaseAddress = new Uri($"https://localhost:5001/graphql/"));
var host = builder.Build();
// Reading Current Culture from LocalStorage
var localStorageService = host.Services.GetRequiredService<ILocalStorageService>();
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
@@ -6,6 +6,10 @@
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>
<ItemGroup>
<None Include="FindAccounts.graphql" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
@@ -11,3 +11,5 @@
@using WotBlitzStatisticsPro.Blazor.Shared
@using Radzen
@using Radzen.Blazor
@using StrawberryShake
@using WotBlitzStatisticsPro.Blazor.GraphQl