本文整理汇总了Java中graphql.schema.DataFetchingEnvironment.getParentType方法的典型用法代码示例。如果您正苦于以下问题:Java DataFetchingEnvironment.getParentType方法的具体用法?Java DataFetchingEnvironment.getParentType怎么用?Java DataFetchingEnvironment.getParentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphql.schema.DataFetchingEnvironment
的用法示例。
在下文中一共展示了DataFetchingEnvironment.getParentType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnbatched
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
public Object getUnbatched(DataFetchingEnvironment env) {
if ( ! isBatched ) return fetcher.get(env);
DataFetchingEnvironment envCopy =
new DataFetchingEnvironmentImpl(
Collections.singletonList(env.getSource()),
env.getArguments(),
env.getContext(),
env.getFields(),
env.getFieldType(),
env.getParentType(),
env.getGraphQLSchema(),
env.getFragmentsByName(),
env.getExecutionId(),
env.getSelectionSet());
Object result = fetcher.get(envCopy);
if ( !(result instanceof List) || ((List)result).size() != 1 ) {
throw new IllegalStateException("Batched fetcher "+fetcher+" expected to return list of 1");
}
return ((List)result).get(0);
}
示例2: ResolutionEnvironment
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
public ResolutionEnvironment(DataFetchingEnvironment env, ValueMapper valueMapper, GlobalEnvironment globalEnvironment) {
this.context = env.getSource();
this.rootContext = env.getContext();
this.valueMapper = valueMapper;
this.globalEnvironment = globalEnvironment;
this.fields = env.getFields();
this.fieldType = env.getFieldType();
this.parentType = env.getParentType();
this.graphQLSchema = env.getGraphQLSchema();
this.dataFetchingEnvironment = env;
}
示例3: Environment
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
public Environment(DataFetchingEnvironment environment) {
Map<String, Object> args = environment.getArguments();
requestScope = (GraphQLRequestScope) environment.getContext();
filters = Optional.ofNullable((String) args.get(ModelBuilder.ARGUMENT_FILTER));
offset = Optional.ofNullable((String) args.get(ModelBuilder.ARGUMENT_AFTER));
first = Optional.ofNullable((String) args.get(ModelBuilder.ARGUMENT_FIRST));
sort = Optional.ofNullable((String) args.get(ModelBuilder.ARGUMENT_SORT));
parentType = environment.getParentType();
outputType = environment.getFieldType();
rawSource = environment.getSource();
container = isRoot() ? new RootContainer() : (GraphQLContainer) rawSource;
if (rawSource instanceof PersistentResourceContainer) {
parentResource = ((PersistentResourceContainer) rawSource).getPersistentResource();
} else {
parentResource = null;
}
field = environment.getFields().get(0);
this.ids = Optional.ofNullable((List<String>) args.get(ModelBuilder.ARGUMENT_IDS));
List<Map<String, Object>> data;
if (args.get(ModelBuilder.ARGUMENT_DATA) instanceof Map) {
data = Arrays.asList((Map<String, Object>) args.get(ModelBuilder.ARGUMENT_DATA));
} else {
data = (List<Map<String, Object>>) args.get(ModelBuilder.ARGUMENT_DATA);
}
this.data = Optional.ofNullable(data);
}