Esempio n. 1
0
        public HeroCategoryGraphType(
            IHeroGrainClient heroGrainClient
            )
        {
            Name        = "HeroCategory";
            Description = "A Hero category grouping.";

            Field(x => x.Id).Description("Hero category unique key.");
            Field(x => x.Title).Description("Hero Category title.");
            Field <ListGraphType <HeroGraphType> >("heroes", resolve: ctx => heroGrainClient.GetAllByRefs(ctx.Source.Heroes), description: "Heroes in category.");
        }
Esempio n. 2
0
        public AppGraphQuery(
            IHeroGrainClient heroGrainClient,
            IHeroCategoryGrainClient heroCategoryGrainClient,
            IHeroStatsGrainClient heroStatsClient,
            IHeroService mockHeroService
            )
        {
            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 =>
            {
                var result = heroGrainClient.Get(context.GetArgument <string>("key"));
                return(result);
            }
                );

            Field <ListGraphType <HeroCategoryGraphType> >(
                name: "heroCategories",
                description: "hero categories",
                resolve: context =>
            {
                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 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 =>
            {
                var result = heroStatsClient.Get(context.GetArgument <string>("key"));
                return(result);
            }
                );


            Field <ListGraphType <HeroGraphType> >(
                name: "heroesMock",
                description: "heroes list",
                resolve: context =>
            {
                var result = mockHeroService.Heroes();
                return(result);
            }
                );
        }
Esempio n. 3
0
 public HeroesController(
     IHeroGrainClient client
     )
 {
     _client = client;
 }