use of graphql.language.NullValue in project graphql-java by graphql-java.
the class SchemaGeneratorHelper method buildValue.
public Object buildValue(Value value, GraphQLType requiredType) {
Object result = null;
if (requiredType instanceof GraphQLNonNull) {
requiredType = ((GraphQLNonNull) requiredType).getWrappedType();
}
if (requiredType instanceof GraphQLScalarType) {
result = parseLiteral(value, (GraphQLScalarType) requiredType);
} else if (value instanceof EnumValue && requiredType instanceof GraphQLEnumType) {
result = ((EnumValue) value).getName();
} else if (value instanceof ArrayValue && requiredType instanceof GraphQLList) {
ArrayValue arrayValue = (ArrayValue) value;
GraphQLType wrappedType = ((GraphQLList) requiredType).getWrappedType();
result = arrayValue.getValues().stream().map(item -> this.buildValue(item, wrappedType)).collect(Collectors.toList());
} else if (value instanceof ObjectValue && requiredType instanceof GraphQLInputObjectType) {
result = buildObjectValue((ObjectValue) value, (GraphQLInputObjectType) requiredType);
} else if (value != null && !(value instanceof NullValue)) {
Assert.assertShouldNeverHappen("cannot build value of %s from %s", requiredType.getName(), String.valueOf(value));
}
return result;
}
Aggregations