Exemplo n.º 1
0
 public Task <Department> GetDepartment(
     IResolverContext ctx,
     [DataLoader] DepartmentLoader loader)
 {
     if (ctx.IsSingleField("id"))
     {
         return(Task.FromResult(new Department {
             Id = DepartmentId
         }));
     }
     return(loader.LoadRequiredAsync(DepartmentId));
 }
Exemplo n.º 2
0
 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")));
 }