public AppQuery( IAuthorService authorService, IPodcastService podcastService, IEpisodeService episodeService ) { Field <ListGraphType <AuthorType> >( "authors", resolve: context => authorService.GetAll() ); Field <AuthorType>( "author", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" } ), resolve: context => { var id = context.GetArgument <int>("id"); return(authorService.GetAuthorById(id)); } ); Field <ListGraphType <PodcastType> >( "podcasts", resolve: context => podcastService.GetAll() ); Field <PodcastType>( "podcast", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" } ), resolve: context => { var id = context.GetArgument <int>("id"); return(podcastService.GetPodcastById(id)); } ); Field <ListGraphType <EpisodeType> >( "episodes", resolve: context => episodeService.GetAll() ); Field <EpisodeType>( "episode", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" } ), resolve: context => { var id = context.GetArgument <int>("id"); return(episodeService.GetEpisodeById(id)); } ); }
public Query(ICharacterService characterService, IEpisodeService episodeService) { Name = "Query"; // Expose characters Field <ListGraphType <CharacterType> >("characters", resolve: (context) => characterService.GetAll()); // Expose episodes Field <ListGraphType <EpisodeType> >("episodes", resolve: (context) => episodeService.GetAll()); }
public async Task <EpisodeRoot> GetAll() { try { return(await _episodeService.GetAll()); } catch (Exception ex) { Debug.WriteLine(ex); } return(null); }
private static async Task <IEnumerable <Episode> > GetAllEpisodesForCharacter(IEpisodeService episodeService, string characterName) { var allEpisodes = await episodeService.GetAll(); return(allEpisodes.Where(e => e.scenes.SelectMany(s => s.characters).Any(c => c.name == characterName))); }