public TournamentType(ITournamentCategoryRepository tournamentCategoryRepository, IBracketRepository bracketRepository, IUserRepository userRepository) { Name = "Tournament"; Description = "Represents a tournament."; Field(_ => _.ID).Name("id").Description("The tournament ID."); Field(_ => _.Name).Name("name").Description("The tournament name."); Field <TournamentCategoryType>( "category", Description = "The tournament's category.", resolve: context => { var parent = context.Source; return(tournamentCategoryRepository.GetTournamentCategoryByID(parent.CategoryID)); }); Field <ListGraphType <BracketType> >( "brackets", Description = "Kategoriye ait urunler", resolve: context => { var parent = context.Source; return(bracketRepository.GetBrackets(_ => _.TournamentID == parent.ID)); }); Field <UserType>( "admin", Description = "Kategoriye ait urunler", resolve: context => { var parent = context.Source; return(userRepository.GetUserByID(parent.AdministratorID)); }); }
public ChallengerQuery(ITournamentRepository tournamentRepository, ITournamentCategoryRepository tournamentCategoryRepository) { Field <TournamentCategoryType>( "category", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id" } ), resolve: context => { var id = context.GetArgument <int>("id"); return(tournamentCategoryRepository.GetTournamentCategoryByID(id)); } ); Field <ListGraphType <TournamentCategoryType> >( "categories", Description = "All tournament categories.", resolve: context => { return(tournamentCategoryRepository.GetTournamentCategories()); } ); Field <TournamentType>( "tournament", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id" } ), resolve: context => { var id = context.GetArgument <int>("id"); return(tournamentRepository.GetTournamentByID(id)); } ); Field <ListGraphType <TournamentType> >( "tournaments", Description = "Tum Urunler", resolve: context => { return(tournamentRepository.GetTournaments()); } ); }