public Task <Department> GetDepartment( IResolverContext ctx, [DataLoader] DepartmentLoader loader) { if (ctx.IsSingleField("id")) { return(Task.FromResult(new Department { Id = DepartmentId })); } return(loader.LoadRequiredAsync(DepartmentId)); }
public Task <Employee?> GetSupervisor( IResolverContext ctx, [DataLoader] EmployeeLoader loader) { if (SupervisorId == null) { return(Task <Employee?> .FromResult <Employee?>(null)); } if (ctx.IsSingleField("id")) { return(Task.FromResult <Employee?>(new Employee { Id = SupervisorId ?? 0 })); } return(loader.LoadOptionalAsync(SupervisorId ?? throw new InvalidOperationException("Internal bug"))); }