com.nebula.boxes.mould.fetcher.ResumeEduDataFetcher Maven / Gradle / Ivy
The newest version!
package com.nebula.boxes.mould.fetcher;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import com.nebula.boxes.mould.fetcher.loader.ResumeEduDataLoader;
import org.dataloader.DataLoader;
import org.springframework.context.annotation.Lazy;
import org.springframework.beans.factory.annotation.Autowired;
import com.nebula.boxes.mould.entity.ResumeEdu;
import com.nebula.boxes.mould.service.IResumeEduService;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsData;
import com.netflix.graphql.dgs.DgsDataFetchingEnvironment;
import com.netflix.graphql.dgs.InputArgument;
import com.spring.boxes.dollar.support.ContextAwarePoolExecutor;
import graphql.schema.DataFetchingEnvironment;
import lombok.extern.slf4j.Slf4j;
/**
* 简历-教育经验 Fetcher
*/
@Lazy
@Slf4j
@DgsComponent
public class ResumeEduDataFetcher {
@Autowired
private IResumeEduService resumeEduService;
@Autowired
private ContextAwarePoolExecutor contextAwarePoolExecutor;
@DgsData(parentType = "Query", field = "getResumeEduById")
public CompletableFuture getResumeEduById(DataFetchingEnvironment dfe) {
DgsDataFetchingEnvironment environment = (DgsDataFetchingEnvironment) dfe;
long id = environment.getArgument("id");
DataLoader dataLoader = environment.getDataLoader(ResumeEduDataLoader.class);
return dataLoader.load(id);
}
@DgsData(parentType = "Query", field = "getResumeEduByIds")
public CompletableFuture> getResumeEduByIds(DataFetchingEnvironment dfe) {
DgsDataFetchingEnvironment environment = (DgsDataFetchingEnvironment) dfe;
List ids = environment.getArgument("ids");
DataLoader dataLoader = environment.getDataLoader(ResumeEduDataLoader.class);
return dataLoader.loadMany(ids);
}
}