graphql.solon.annotation.BatchMappingAnnoHandler Maven / Gradle / Ivy
package graphql.solon.annotation;
import graphql.schema.DataFetcher;
import graphql.solon.execution.BatchLoaderRegistry;
import graphql.solon.fetcher.BatchMappingDataFetcher;
import graphql.solon.fetcher.DataFetcherWrap;
import graphql.solon.util.ClazzUtil;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Callable;
import org.apache.commons.lang3.StringUtils;
import org.noear.solon.Utils;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.BeanWrap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* @author fuzi1996
* @since 2.3
*/
public class BatchMappingAnnoHandler extends BaseSchemaMappingAnnoHandler {
private static Logger log = LoggerFactory.getLogger(BatchMappingAnnoHandler.class);
public BatchMappingAnnoHandler(AppContext context) {
super(context);
}
@Override
public void doExtract(BeanWrap wrap, Method method,
BatchMapping schemaMapping) throws Throwable {
String typeName = this.getTypeName(wrap, method, schemaMapping);
String fieldName = this.getFieldName(wrap, method, schemaMapping);
if (StringUtils.isBlank(typeName)) {
Parameter[] parameters = method.getParameters();
for (Parameter parameter : parameters) {
if (Collection.class.isAssignableFrom(parameter.getType())) {
typeName = ClazzUtil.getGenericReturnClass(parameter.getParameterizedType())
.getSimpleName();
break;
}
}
}
DataFetcher
© 2015 - 2025 Weber Informatics LLC | Privacy Policy