本文整理汇总了Java中graphql.schema.DataFetchingEnvironment.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java DataFetchingEnvironment.getArguments方法的具体用法?Java DataFetchingEnvironment.getArguments怎么用?Java DataFetchingEnvironment.getArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphql.schema.DataFetchingEnvironment
的用法示例。
在下文中一共展示了DataFetchingEnvironment.getArguments方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Customer get(DataFetchingEnvironment environment) {
Map arguments = environment.getArguments();
Customer customer = new Customer();
if(arguments.get("id") != null){
customer.setId(Long.parseLong(arguments.get("id").toString()));
}
customer.setFirstName(arguments.get("firstName").toString());
customer.setLastName(arguments.get("lastName").toString());
if(arguments.get("accounts") != null){
ArrayList array = (ArrayList) arguments.get("accounts");
for(Object o: array){
Map m = (Map)o;
String accountName = m.get("accountName").toString();
}
}
customer = customerRepository.save(customer);
return customer;
}
示例2: 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);
}
示例3: unwrapInputArguments
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
protected Map<String, Object> unwrapInputArguments(DataFetchingEnvironment environment) {
Map<String, Object> inputObject = null;
String inArgName = getGraphQLSchemaConfig().getMutationInputArgumentName();
if (environment.getArguments() != null && (environment.getArguments() instanceof Map)) {
inputObject = (Map<String, Object>) environment.getArguments().get(inArgName);
}
return inputObject;
}
示例4: 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);
}
示例5: instanceMethodWithArgument
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@GraphQLField
public static String instanceMethodWithArgument(@GraphQLName("arg1") String arg1,
DataFetchingEnvironment env) {
((PhantasmCRUD) env.getContext()).getModel(); // ensure it isn't null;
env.getArguments(); // not null;
passThrough.set(arg1);
return ((Thing1) env.getSource()).getThing2()
.getName();
}
示例6: get
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Customer get(DataFetchingEnvironment environment) {
Map arguments = environment.getArguments();
return customerRepository.findOne(Long.parseLong(arguments.get("id").toString()));
}
示例7: get
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
/**
* Override graphql-java's {@link DataFetcher} get method to execute
* the mutation and return some sensible output values.
* @param environment Graphql-java's execution environment
* @return a collection of {@link PersistentResource} objects
*/
@Override
public Object get(DataFetchingEnvironment environment) {
/* fetch arguments in mutation/query */
Map<String, Object> args = environment.getArguments();
/* fetch current operation */
RelationshipOp operation = (RelationshipOp) args.getOrDefault(ARGUMENT_OPERATION, RelationshipOp.FETCH);
/* build environment object, extracts required fields */
Environment context = new Environment(environment);
/* safe enable debugging */
if (log.isDebugEnabled()) {
logContext(operation, context);
}
/* sanity check for pagination/filtering/sorting arguments w any operation other than FETCH */
if (operation != RelationshipOp.FETCH) {
filterSortPaginateSanityCheck(context);
}
/* delegate request */
switch (operation) {
case FETCH:
return fetchObjects(context);
case UPSERT:
return upsertObjects(context);
case UPDATE:
return updateObjects(context);
case DELETE:
return deleteObjects(context);
case REMOVE:
return removeObjects(context);
case REPLACE:
return replaceObjects(context);
default:
throw new UnsupportedOperationException("Unknown operation: " + operation);
}
}
示例8: constructor
import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Initializer
public static void constructor(DataFetchingEnvironment env) {
((PhantasmCRUD) env.getContext()).getModel(); // ensure it isn't null;
env.getArguments(); // not null;
((Thing1) env.getSource()).setDescription(passThrough.get());
}