diff --git a/NineChronicles.DataProvider.Tests/WorldBossRankingQueryTest.cs b/NineChronicles.DataProvider.Tests/WorldBossRankingQueryTest.cs index 4faa5f60..0fc28629 100644 --- a/NineChronicles.DataProvider.Tests/WorldBossRankingQueryTest.cs +++ b/NineChronicles.DataProvider.Tests/WorldBossRankingQueryTest.cs @@ -17,12 +17,15 @@ public class WorldBossRankingQueryTest : TestBase, IDisposable [Fact] public async Task WorldBossRanking() { - const string query = @"query { - worldBossRanking(raidId: 1) { - ranking - avatarName - } - }"; + const string query = $@"query {{ + worldBossRanking(raidId: 1) {{ + blockIndex + rankingInfo {{ + ranking + avatarName + }} + }} + }}"; for (int idx = 0; idx < 2; idx++) { for (int i = 0; i < 200; i++) @@ -43,7 +46,9 @@ public async Task WorldBossRanking() await Context.SaveChangesAsync(); var result = await ExecuteAsync(query); - var models = (object[])((Dictionary) ((ExecutionNode) result.Data).ToValue())["worldBossRanking"]; + var data = (Dictionary)((Dictionary) ((ExecutionNode) result.Data).ToValue())["worldBossRanking"]; + Assert.Equal(0L, data["blockIndex"]); + var models = (object[]) data["rankingInfo"]; Assert.Equal(100, models.Length); } diff --git a/NineChronicles.DataProvider/GraphTypes/WorldBossRankingInfoType.cs b/NineChronicles.DataProvider/GraphTypes/WorldBossRankingInfoType.cs new file mode 100644 index 00000000..d360072c --- /dev/null +++ b/NineChronicles.DataProvider/GraphTypes/WorldBossRankingInfoType.cs @@ -0,0 +1,21 @@ +namespace NineChronicles.DataProvider.GraphTypes +{ + using System.Collections.Generic; + using GraphQL.Types; + using NineChronicles.DataProvider.Store.Models; + + public class WorldBossRankingInfoType : ObjectGraphType<(long blockIndex, List worldBossRankingModels)> + { + public WorldBossRankingInfoType() + { + Field>( + "blockIndex", + resolve: context => context.Source.blockIndex + ); + Field>>( + "rankingInfo", + resolve: context => context.Source.worldBossRankingModels + ); + } + } +} diff --git a/NineChronicles.DataProvider/Queries/NineChroniclesSummaryQuery.cs b/NineChronicles.DataProvider/Queries/NineChroniclesSummaryQuery.cs index b02e3d59..000bc77f 100644 --- a/NineChronicles.DataProvider/Queries/NineChroniclesSummaryQuery.cs +++ b/NineChronicles.DataProvider/Queries/NineChroniclesSummaryQuery.cs @@ -210,7 +210,7 @@ public NineChroniclesSummaryQuery(MySqlStore store, StandaloneContext standalone name: "dauQuery", resolve: context => new DauQuery(store) ); - Field>( + Field( name: "worldBossRanking", arguments: new QueryArguments( new QueryArgument> @@ -248,7 +248,7 @@ public NineChroniclesSummaryQuery(MySqlStore store, StandaloneContext standalone } } - return result; + return (StandaloneContext.BlockChain?.Tip?.Index ?? 0, result); }); Field( name: "worldBossTotalUsers",