use of graphql.schema.CoercingSerializeException in project graphql-java by graphql-java.
the class ExecutionResultJSONTesting method createER.
private ExecutionResult createER() {
List<GraphQLError> errors = new ArrayList<>();
errors.add(new ValidationError(ValidationErrorType.UnknownType, mkLocations(), "Test ValidationError"));
errors.add(new MissingRootTypeException("Mutations are not supported.", null));
errors.add(new InvalidSyntaxError(mkLocations(), "Not good syntax m'kay"));
errors.add(new NonNullableFieldWasNullError(new NonNullableFieldWasNullException(mkTypeInfo(), mkPath())));
errors.add(new SerializationError(mkPath(), new CoercingSerializeException("Bad coercing")));
errors.add(new ExceptionWhileDataFetching(mkPath(), new RuntimeException("Bang"), mkLocation(666, 999)));
return new ExecutionResultImpl(null, errors);
}
use of graphql.schema.CoercingSerializeException in project graphql-java by graphql-java.
the class ExecutionStrategy method completeValueForEnum.
/**
* Called to turn an object into a enum value according to the {@link GraphQLEnumType} by asking that enum type to coerce the object into a valid value
*
* @param executionContext contains the top level execution parameters
* @param parameters contains the parameters holding the fields to be executed and source object
* @param enumType the type of the enum
* @param result the result to be coerced
*
* @return an {@link ExecutionResult}
*/
protected CompletableFuture<ExecutionResult> completeValueForEnum(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLEnumType enumType, Object result) {
Object serialized;
try {
serialized = enumType.getCoercing().serialize(result);
} catch (CoercingSerializeException e) {
serialized = handleCoercionProblem(executionContext, parameters, e);
}
serialized = parameters.getNonNullFieldValidator().validate(parameters.getPath(), serialized);
return completedFuture(new ExecutionResultImpl(serialized, null));
}
use of graphql.schema.CoercingSerializeException in project graphql-java by graphql-java.
the class ExecutionStrategy method completeValueForScalar.
/**
* Called to turn an object into a scalar value according to the {@link GraphQLScalarType} by asking that scalar type to coerce the object
* into a valid value
*
* @param executionContext contains the top level execution parameters
* @param parameters contains the parameters holding the fields to be executed and source object
* @param scalarType the type of the scalar
* @param result the result to be coerced
*
* @return an {@link ExecutionResult}
*/
protected CompletableFuture<ExecutionResult> completeValueForScalar(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLScalarType scalarType, Object result) {
Object serialized;
try {
serialized = scalarType.getCoercing().serialize(result);
} catch (CoercingSerializeException e) {
serialized = handleCoercionProblem(executionContext, parameters, e);
}
// 6.6.1 http://facebook.github.io/graphql/#sec-Field-entries
if (serialized instanceof Double && ((Double) serialized).isNaN()) {
serialized = null;
}
serialized = parameters.getNonNullFieldValidator().validate(parameters.getPath(), serialized);
return completedFuture(new ExecutionResultImpl(serialized, null));
}
Aggregations