-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gql): remove deprecations + fixed (#65)
- Loading branch information
1 parent
da8f211
commit a5e1972
Showing
3 changed files
with
28 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,48 @@ | ||
using GraphQL; | ||
using Heroes.Contracts.HeroCategories; | ||
using Heroes.Contracts.Heroes; | ||
using Heroes.Contracts.Stats; | ||
using Heroes.Server.Gql.Types; | ||
using Heroes.Server.Sample; | ||
|
||
namespace Heroes.Server.Gql; | ||
|
||
public class AppGraphQuery : ObjectGraphType | ||
{ | ||
public AppGraphQuery( | ||
IHeroGrainClient heroGrainClient, | ||
IHeroCategoryGrainClient heroCategoryGrainClient, | ||
IHeroStatsGrainClient heroStatsClient, | ||
IHeroService mockHeroService | ||
IHeroCategoryGrainClient heroCategoryGrainClient | ||
) | ||
{ | ||
Name = "AppQueries"; | ||
|
||
Field<HeroGraphType>( | ||
name: "hero", | ||
description: "hero full object", | ||
arguments: new QueryArguments( | ||
new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "key", Description = "Unique key for specific hero" } | ||
), | ||
resolve: context => | ||
Field<HeroGraphType, Hero>("hero") | ||
.Description("Hero entry.") | ||
.Argument<StringGraphType>("key", "Unique key.") | ||
.ResolveAsync(ctx => | ||
{ | ||
var result = heroGrainClient.Get(context.GetArgument<string>("key")); | ||
var result = heroGrainClient.Get(ctx.GetArgument<string>("key")); | ||
return result; | ||
} | ||
); | ||
}) | ||
; | ||
|
||
Field<ListGraphType<HeroCategoryGraphType>>( | ||
name: "heroCategories", | ||
description: "hero categories", | ||
resolve: context => | ||
Field<ListGraphType<HeroGraphType>, List<Hero>>("heroes") | ||
.Description("All available Heroes.") | ||
.Argument<HeroRoleGraphType>("role", "Filter by role.") | ||
.ResolveAsync(ctx => | ||
{ | ||
var result = heroCategoryGrainClient.GetAll(); | ||
return result; | ||
} | ||
); | ||
|
||
Field<ListGraphType<HeroGraphType>>( | ||
name: "heroes", | ||
description: "heroes list", | ||
arguments: new QueryArguments( | ||
new QueryArgument<HeroRoleGraphType> { Name = "role", Description = "filtering heroes by role." } | ||
), | ||
resolve: context => | ||
{ | ||
var role = context.GetArgument<int?>("role"); | ||
var role = ctx.GetArgument<int?>("role"); | ||
var result = heroGrainClient.GetAll((HeroRoleType?)role); | ||
return result; | ||
} | ||
); | ||
}) | ||
; | ||
|
||
Field<HeroStatsGraphType>( | ||
name: "herostats", | ||
description: "view all hero stats", | ||
arguments: new QueryArguments( | ||
new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "key", Description = "Unique key for specific hero" } | ||
), | ||
resolve: context => | ||
Field<ListGraphType<HeroCategoryGraphType>, List<HeroCategory>>("heroCategories") | ||
.Description("All hero categories.") | ||
.ResolveAsync(ctx => | ||
{ | ||
var result = heroStatsClient.Get(context.GetArgument<string>("key")); | ||
var result = heroCategoryGrainClient.GetAll(); | ||
return result; | ||
} | ||
); | ||
|
||
}) | ||
; | ||
|
||
Field<ListGraphType<HeroGraphType>>( | ||
name: "heroesMock", | ||
description: "heroes list", | ||
resolve: context => | ||
{ | ||
var result = mockHeroService.Heroes(); | ||
return result; | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters