Exemplo n.º 1
0
 public HeroesController(IHeroClient client)
 {
     _client = client;
 }
Exemplo n.º 2
0
        public HeroesAppGraphQuery(
            IHeroClient heroClient,
            IHeroStatsClient heroStatsClient,
            IHeroService mockHeroService
            )
        {
            Name = "AppQueries";

            Field <HeroType>(
                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 = heroClient.Get(context.GetArgument <string>("key"));
                return(result);
            }
                );

            Field <ListGraphType <HeroType> >(
                name: "heroes",
                description: "heroes list",
                arguments: new QueryArguments(
                    new QueryArgument <HeroRoleEnum> {
                Name = "role", Description = "filtering heroes by role."
            }
                    ),
                resolve: context =>
            {
                var role   = context.GetArgument <int?>("role");
                var result = heroClient.GetAll((HeroRoleType?)role);
                return(result);
            }
                );

            Field <HeroStatsType>(
                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 <HeroType> >(
                name: "heroesMock",
                description: "heroes list",
                resolve: context =>
            {
                var result = mockHeroService.Heroes();
                return(result);
            }
                );
        }
Exemplo n.º 3
0
 public HeroController(ILogger <HeroController> logger)
 {
     _logger     = logger;
     _heroClient = RestService.For <IHeroClient>("https://superheroapi.com");
 }