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


Java DataFetchingEnvironment.getSource方法代码示例

本文整理汇总了Java中graphql.schema.DataFetchingEnvironment.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java DataFetchingEnvironment.getSource方法的具体用法?Java DataFetchingEnvironment.getSource怎么用?Java DataFetchingEnvironment.getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphql.schema.DataFetchingEnvironment的用法示例。


在下文中一共展示了DataFetchingEnvironment.getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
  Object source = environment.getSource();
  if (source == null) {
    return null;
  }
  if (source instanceof Map) {
    return ((Map<?, ?>) source).get(name);
  }
  GraphQLType type = environment.getFieldType();
  if (type instanceof GraphQLNonNull) {
    type = ((GraphQLNonNull) type).getWrappedType();
  }
  if (type instanceof GraphQLList) {
    return call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name) + "List");
  }
  if (type instanceof GraphQLEnumType) {
    Object o = call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name));
    if (o != null) {
      return o.toString();
    }
  }

  return call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name));
}
 
开发者ID:google,项目名称:rejoiner,代码行数:26,代码来源:ProtoToGql.java

示例2: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Batched
@Override
public Object get(DataFetchingEnvironment env) {
    List<Object> unresolved = new ArrayList<>();
    Object result;
    int depth = listDepth;
    if ( env.getSource() instanceof List ) { // batched.
        result = getBatched(env);
        if ( null != resolver ) addUnresolved(unresolved, result, ++depth);
    } else {
        result = getUnbatched(env);
        if ( null != resolver ) addUnresolved(unresolved, result, depth);
    }
    if ( null == resolver ) return result;
    return replaceResolved(result, resolver.resolve(unresolved).iterator(), depth);
}
 
开发者ID:Distelli,项目名称:graphql-apigen,代码行数:17,代码来源:ResolverDataFetcher.java

示例3: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
    Object targetMethodResult = null;
    try {

        beforeInvocation(environment);

        Object[] bindByClassValues = collectBindByClassValues(environment);
        Object[] inputArguments = getMethodParametersBinder().bindParameters(environment.getArguments(), bindByClassValues);
        if (isAllNulls(inputArguments) && canApplySourceObject(environment)) {
            inputArguments = new Object[]{environment.getSource()};
        }
        targetMethodResult = getTargetMethod().invoke(getTargetObject(), inputArguments);

        targetMethodResult = afterInvocation(environment, targetMethodResult);

    } catch (Exception e) {
        String msg = "Exception while calling data fetcher [" + getTargetMethod().getName() + "]";
        if (LOGGER.isErrorEnabled())
            LOGGER.error(msg, e);
        throw new DataFetcherRuntimeException(msg, e);
    }

    return targetMethodResult;
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:26,代码来源:ReflectionGraphQLDataFetcher.java

示例4: parentNodeFetcher

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
/**
 * Fetcher for the parent node reference of a node.
 * 
 * @param env
 * @return
 */
public Object parentNodeFetcher(DataFetchingEnvironment env) {
	NodeContent content = env.getSource();
	if (content == null) {
		return null;
	}
	GraphQLContext gc = env.getContext();
	String uuid = gc.getRelease().getUuid();
	Node parentNode = content.getNode().getParentNode(uuid);
	// The project root node can have no parent. Lets check this and exit early.
	if (parentNode == null) {
		return null;
	}
	gc.requiresPerm(parentNode, READ_PERM, READ_PUBLISHED_PERM);
	return handleLanguageFallback(gc, parentNode, content);
}
 
开发者ID:gentics,项目名称:mesh,代码行数:22,代码来源:NodeTypeProvider.java

示例5: nodeLanguageFetcher

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
public Object nodeLanguageFetcher(DataFetchingEnvironment env) {
	NodeContent content = env.getSource();
	if (content == null) {
		return null;
	}
	List<String> languageTags = getLanguageArgument(env);
	GraphQLContext gc = env.getContext();

	Node node = content.getNode();
	Release release = gc.getRelease();
	NodeGraphFieldContainer container = node.findVersion(gc, languageTags);
	// There might not be a container for the selected language (incl. fallback language)
	if (container == null) {
		return null;
	}

	// Check whether the user is allowed to read the published container
	boolean isPublished = container.isPublished(release.getUuid());
	if (isPublished) {
		gc.requiresPerm(node, READ_PERM, READ_PUBLISHED_PERM);
	} else {
		// Otherwise the container is a draft and we need to use the regular read permission
		gc.requiresPerm(node, READ_PERM);
	}
	return new NodeContent(node, container);
}
 
开发者ID:gentics,项目名称:mesh,代码行数:27,代码来源:NodeTypeProvider.java

示例6: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
    List<ErrorCount> errorCounts = new ArrayList();
    Map<String, Object> parentFeedMap = environment.getSource();
    String namespace = (String) parentFeedMap.get("namespace");
    Connection connection = null;
    try {
        connection = GTFSGraphQL.getConnection();
        Statement statement = connection.createStatement();
        String sql = String.format("select error_type, count(*) from %s.errors group by error_type", namespace);
        LOG.info("SQL: {}", sql);
        if (statement.execute(sql)) {
            ResultSet resultSet = statement.getResultSet();
            while (resultSet.next()) {
                errorCounts.add(new ErrorCount(NewGTFSErrorType.valueOf(resultSet.getString(1)), resultSet.getInt(2)));
            }
        }
    } catch (SQLException e) {
        throw new RuntimeException(e);
    } finally {
        DbUtils.closeQuietly(connection);
    }
    return errorCounts;
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:25,代码来源:ErrorCountFetcher.java

示例7: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Integer get(DataFetchingEnvironment environment) {
    Map<String, Object> parentFeedMap = environment.getSource();
    String namespace = (String) parentFeedMap.get("namespace");
    Connection connection = null;
    try {
        connection = GTFSGraphQL.getConnection();
        Statement statement = connection.createStatement();
        String sql = String.format("select count(*) from %s.%s", namespace, tableName);
        if (statement.execute(sql)) {
            ResultSet resultSet = statement.getResultSet();
            resultSet.next();
            return resultSet.getInt(1);
        }
    } catch (SQLException e) {
        // In case the table doesn't exist in this feed, just return zero and don't print noise to the log.
        // Unfortunately JDBC doesn't seem to define reliable error codes.
        if (! JDBCTableReader.SQL_STATE_UNDEFINED_TABLE.equals(e.getSQLState())) {
            e.printStackTrace();
        }
    } finally {
        DbUtils.closeQuietly(connection);
    }
    return 0;
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:26,代码来源:RowCountFetcher.java

示例8: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
  if (environment.getSource() instanceof SubjectReference) {
    SubjectReference source = environment.getSource();
    if (isList) {
      return inner.getList(
        source,
        argumentsHelper.getPaginationArguments(environment),
        ((DatabaseResult) environment.getSource()).getDataSet()
      );
    } else {
      return inner.getItem(source, ((DatabaseResult) environment.getSource()).getDataSet());
    }
  } else {
    throw new IllegalStateException("Source is not a SubjectReference");
  }
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:18,代码来源:DataFetcherWrapper.java

示例9: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public UserDto get(DataFetchingEnvironment environment) {
    log.info("getSource {}", (Object) environment.getSource());
    OrderDto order = environment.getSource();
    UserDto user = userAdaptor.getUser(order.getUserId());
    return user;
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:8,代码来源:OrderUserFetcher.java

示例10: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public ProductDto get(DataFetchingEnvironment environment) {
    log.info("getSource {}", (Object)environment.getSource());
    OrderItemDto orderItemDto = environment.getSource();
    ProductDto product = productAdaptor.getProduct(orderItemDto.getProductId());
    return product;
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:8,代码来源:OrderItemProductFetcher.java

示例11: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
    SchemaInstance schemaInstance = environment.getSource();
    GraphQLInstanceRequestContext context = environment.getContext();

    return SchemaInstanceReferencedBy.fromSchemaInstances(
            instanceOutputTypeService.findRefereeSchemaInstances(context.getSchemaInstanceKey(),
                    context.getSchemaKey(), schemaInstance.getId()));
}
 
开发者ID:nfl,项目名称:gold,代码行数:10,代码来源:DataFetcherFactory.java

示例12: FetchParams

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
public FetchParams(DataFetchingEnvironment environment, HGQLSchema hgqlschema) {

        subjectResource = environment.getSource();
        String predicate = ((Field) environment.getFields().toArray()[0]).getName();
        predicateURI = hgqlschema.getFields().get(predicate).getId();
        client = environment.getContext();
        if (!environment.getParentType().getName().equals("Query")) {
            String targetName = hgqlschema.getTypes().get(environment.getParentType().getName()).getField(predicate).getTargetName();
            if (hgqlschema.getTypes().containsKey(targetName) && hgqlschema.getTypes().get(targetName).getId()!=null) {
                targetURI=hgqlschema.getTypes().get(targetName).getId();
            }
        }
    }
 
开发者ID:semantic-integration,项目名称:hypergraphql,代码行数:14,代码来源:FetchParams.java

示例13: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment environment) {
	Object result = super.get(environment);
	if (result == null) {
		Object source = environment.getSource();
        if (source == null) return null;
        result = getPropertyViaMethod(source, propertyName);
	}
	result = postProcess(result, environment);
	if (result instanceof Set) {
		// cast all set to list
		result = new ArrayList<>((Set<?>) result);
	}
	return result;
}
 
开发者ID:hivdb,项目名称:sierra,代码行数:16,代码来源:ExtendedFieldDefinition.java

示例14: 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;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:13,代码来源:ResolutionEnvironment.java

示例15: get

import graphql.schema.DataFetchingEnvironment; //导入方法依赖的package包/类
@Override
public Object get(DataFetchingEnvironment env) {
    Object source = ( null != impl ) ? impl : env.getSource();
    if (source == null) return null;
    if (source instanceof ResolveDataFetchingEnvironment) {
        source = ((ResolveDataFetchingEnvironment)source).resolve(env);
    }
    return getMethodViaGetter(source, env.getFieldType(), getFieldType(env.getParentType()), env.getArguments());
}
 
开发者ID:Distelli,项目名称:graphql-apigen,代码行数:10,代码来源:MethodDataFetcher.java


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