当前位置: 首页>>代码示例>>Java>>正文


Java DataFetchingEnvironment.getArguments方法代码示例

本文整理汇总了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;
}
 
开发者ID:rylitalo,项目名称:graphql-with-springboot-jpa-example,代码行数:22,代码来源:SaveCustomerDataFetcher.java

示例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);
}
 
开发者ID:Distelli,项目名称:graphql-apigen,代码行数:21,代码来源:ResolverDataFetcher.java

示例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;
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:9,代码来源:ReflectionGraphQLDataMutator.java

示例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);
}
 
开发者ID:yahoo,项目名称:elide,代码行数:36,代码来源:Environment.java

示例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();
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:10,代码来源:Thing1_Plugin.java

示例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()));
}
 
开发者ID:rylitalo,项目名称:graphql-with-springboot-jpa-example,代码行数:6,代码来源:SingleCustomerDataFetcher.java

示例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);
    }
}
 
开发者ID:yahoo,项目名称:elide,代码行数:52,代码来源:PersistentResourceFetcher.java

示例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());
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:7,代码来源:Thing1_Plugin.java


注:本文中的graphql.schema.DataFetchingEnvironment.getArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。