本文整理汇总了Java中graphql.language.SourceLocation类的典型用法代码示例。如果您正苦于以下问题:Java SourceLocation类的具体用法?Java SourceLocation怎么用?Java SourceLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceLocation类属于graphql.language包,在下文中一共展示了SourceLocation类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sanitize
import graphql.language.SourceLocation; //导入依赖的package包/类
private GraphQLError sanitize(GraphQLError error) {
if (error instanceof ExceptionWhileDataFetching) {
return new GraphQLError() {
@Override
public String getMessage() {
Throwable cause = ((ExceptionWhileDataFetching) error).getException().getCause();
return cause instanceof InvocationTargetException ? ((InvocationTargetException) cause).getTargetException().getMessage() : cause.getMessage();
}
@Override
public List<SourceLocation> getLocations() {
return error.getLocations();
}
@Override
public ErrorType getErrorType() {
return error.getErrorType();
}
};
}
return error;
}
开发者ID:wlindner,项目名称:ReBoot,代码行数:23,代码来源:GraphQlController.java
示例2: execute
import graphql.language.SourceLocation; //导入依赖的package包/类
public <T extends ExecutionResult> T execute() {
assertNotNull(arguments, "Arguments can't be null");
LOGGER.info("Executing request. Operation name: {}. Request: {} ", operationName, requestQuery);
Parser parser = new Parser();
Document document;
try {
document = parser.parseDocument(requestQuery);
} catch (ParseCancellationException e) {
RecognitionException recognitionException = (RecognitionException) e.getCause();
SourceLocation sourceLocation = new SourceLocation(recognitionException.getOffendingToken().getLine(), recognitionException.getOffendingToken().getCharPositionInLine());
InvalidSyntaxError invalidSyntaxError = new InvalidSyntaxError(sourceLocation);
return (T) new GraphQLRxExecutionResult(Observable.just(null), Observable.just(Arrays.asList(invalidSyntaxError)));
}
Validator validator = new Validator();
List<ValidationError> validationErrors = validator.validateDocument(graphQLSchemaHolder.getGraphQLSchema(), document);
if (validationErrors.size() > 0) {
return (T) new GraphQLRxExecutionResult(Observable.just(null), Observable.just(validationErrors));
}
if (executionStrategy == null) {
if (executorService == null) {
executionStrategy = new GraphQLDefaultRxExecutionStrategy(graphQLSchemaHolder, maxQueryDepth, maxQueryComplexity);
} else {
executionStrategy = new GraphQLExecutorServiceRxExecutionStrategy(graphQLSchemaHolder, executorService, maxQueryDepth, maxQueryComplexity);
}
}
RxExecution execution = new RxExecution(graphQLSchemaHolder, maxQueryDepth, maxQueryComplexity, executionStrategy);
ExecutionResult executionResult = execution.execute(graphQLSchemaHolder.getGraphQLSchema(), context, document, operationName, arguments);
return (T) (executionResult instanceof GraphQLRxExecutionResult ?
executionResult : new GraphQLRxExecutionResult(Observable.just(executionResult.getData()), Observable.just(executionResult.getErrors())));
}
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:37,代码来源:GraphQLQueryExecutor.java
示例3: addErrors
import graphql.language.SourceLocation; //导入依赖的package包/类
/**
* Add the listed errors to the response.
*
* @param errors
* @param response
*/
private void addErrors(List<GraphQLError> errors, JsonObject response) {
JsonArray jsonErrors = new JsonArray();
response.put("errors", jsonErrors);
for (GraphQLError error : errors) {
JsonObject jsonError = new JsonObject();
if (error instanceof ExceptionWhileDataFetching) {
ExceptionWhileDataFetching dataError = (ExceptionWhileDataFetching) error;
if (dataError.getException() instanceof PermissionException) {
PermissionException restException = (PermissionException) dataError.getException();
// TODO translate error
// TODO add i18n parameters
jsonError.put("message", restException.getI18nKey());
jsonError.put("type", restException.getType());
jsonError.put("elementId", restException.getElementId());
jsonError.put("elementType", restException.getElementType());
} else {
log.error("Error while fetching data.", dataError.getException());
jsonError.put("message", dataError.getMessage());
jsonError.put("type", dataError.getErrorType());
}
} else {
jsonError.put("message", error.getMessage());
jsonError.put("type", error.getErrorType());
if (error.getLocations() != null && !error.getLocations().isEmpty()) {
JsonArray errorLocations = new JsonArray();
jsonError.put("locations", errorLocations);
for (SourceLocation location : error.getLocations()) {
JsonObject errorLocation = new JsonObject();
errorLocation.put("line", location.getLine());
errorLocation.put("column", location.getColumn());
errorLocations.add(errorLocation);
}
}
}
jsonErrors.add(jsonError);
}
}
开发者ID:gentics,项目名称:mesh,代码行数:44,代码来源:GraphQLHandler.java
示例4: getMessage
import graphql.language.SourceLocation; //导入依赖的package包/类
@Override
public String getMessage() {
String result = "";
for (GraphQLError error : errors) {
result += error.getErrorType() + ": " + error.getMessage() + "\n";
for (SourceLocation sourceLocation : error.getLocations()) {
result += " at line: " + sourceLocation.getLine() + " column: " + sourceLocation.getColumn();
}
}
return result;
}
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:12,代码来源:GraphQlFailedException.java
示例5: getLocations
import graphql.language.SourceLocation; //导入依赖的package包/类
@Override
public List<SourceLocation> getLocations() {
return error.getLocations();
}
开发者ID:eh3rrera,项目名称:graphql-java-spring-boot-example,代码行数:5,代码来源:GraphQLErrorAdapter.java
示例6: getLocations
import graphql.language.SourceLocation; //导入依赖的package包/类
@Override
public List<SourceLocation> getLocations() {
return null;
}
开发者ID:eh3rrera,项目名称:graphql-java-spring-boot-example,代码行数:5,代码来源:BookNotFoundException.java
示例7: buildErrorResult
import graphql.language.SourceLocation; //导入依赖的package包/类
GraphQLResult buildErrorResult(final String message) {
return new GraphQLResult() {
@Override
public boolean isSuccessful() {
return false;
}
@SuppressWarnings("unchecked")
@Override
public Object getData() {
return null;
}
@Override
public List<GraphQLError> getErrors() {
return Collections.singletonList(new GraphQLError() {
@Override
public String getMessage() {
return message;
}
@Override
public List<SourceLocation> getLocations() {
return Collections.emptyList();
}
@Override
public ErrorType getErrorType() {
return ErrorType.ValidationError;
}
});
}
@Override
public Map<Object, Object> getExtensions() {
return Collections.emptyMap();
}
@Override
public Map<String, Object> toSpecification() {
return Collections.emptyMap();
}
};
}
开发者ID:nfl,项目名称:gold,代码行数:46,代码来源:GraphQLBaseService.java
示例8: validateQuery
import graphql.language.SourceLocation; //导入依赖的package包/类
public ValidatedQuery validateQuery(String query) {
ValidatedQuery result = new ValidatedQuery();
result.errors = validationErrors;
Document document;
try {
document = parser.parseDocument(query);
result.parsedQuery = document;
} catch (Exception e) {
ValidationError err = new ValidationError(ValidationErrorType.InvalidSyntax, new SourceLocation(0, 0), "Invalid query syntax.");
validationErrors.add(err);
result.valid = false;
return result;
}
validationErrors.addAll(validator.validateDocument(schema, document));
if (validationErrors.size() > 0) {
result.valid = false;
return result;
}
result.valid = true;
return result;
}
开发者ID:semantic-integration,项目名称:hypergraphql,代码行数:34,代码来源:QueryValidator.java
注:本文中的graphql.language.SourceLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论