private async Task <IEnumerable <Log> > GetLogFunc(IResolveFieldContext <object> context) { var logId = context.GetArgument <string>("logId"); if (logId != null) { var log = await _logEngine.GetLog(logId); return(new List <Log> { log }); } var missionId = context.GetArgument <string>("missionId"); if (missionId != null) { return(await _logEngine.GetLogsByMissionId(missionId)); } var seriesId = context.GetArgument <string>("seriesId"); if (seriesId != null) { return(await _logEngine.GetLogsBySeriesId(seriesId)); } return(await _logEngine.GetAll()); }
public MissionType(ISeriesEngine seriesEngine, IFileEngine fileEngine, ILogEngine logEngine) { Name = "Mission"; Description = "A set of missions that contributed to a larger objective"; // Auto-mapped properties Field(s => s.Id); Field(s => s.MissionName).Description("The name of the mission."); // Custom-mapped properties Field <ListGraphType <SpeakerType> >("speakers", "Speakers whose voice was recorded in logs during this mission.", resolve: c => c.Source.Speakers); Field <FileType>("file", "Image associated with the mission.", resolve: c => fileEngine.GetById(c.Source.FileId)); Field <SeriesType>("series", "The series this mission was a part of.", resolve: c => seriesEngine.GetSeries(c.Source.SeriesId)); Field <ListGraphType <LogType> >("log", "Logs that were captured as part of this mission.", resolve: c => logEngine.GetLogsByMissionId(c.Source.Id)); Field <LongGraphType>("logCount", "Number of logs that were captured as part of this mission.", resolve: c => logEngine.GetLogCountByMissionId(c.Source.Id)); }