use of com.yahoo.elide.core.utils.coerce.converters.ElideTypeConverter in project elide by yahoo.
the class GraphQLConversionUtils method registerCustomScalars.
private void registerCustomScalars() {
CoerceUtil.getSerdes().forEach((type, serde) -> {
SerdeCoercing<?, ?> serdeCoercing = new SerdeCoercing<>(ERROR_MESSAGE, serde);
ElideTypeConverter elideTypeConverter = serde.getClass().getAnnotation(ElideTypeConverter.class);
String name = elideTypeConverter != null ? elideTypeConverter.name() : type.getSimpleName();
String description = elideTypeConverter != null ? elideTypeConverter.description() : type.getSimpleName();
scalarMap.put(ClassType.of(type), GraphQLScalarType.newScalar().name(name).description(description).coercing(serdeCoercing).build());
});
}
use of com.yahoo.elide.core.utils.coerce.converters.ElideTypeConverter in project elide by yahoo.
the class Elide method registerCustomSerde.
protected void registerCustomSerde() {
Injector injector = elideSettings.getDictionary().getInjector();
Set<Class<?>> classes = registerCustomSerdeScan();
for (Class<?> clazz : classes) {
if (!Serde.class.isAssignableFrom(clazz)) {
log.warn("Skipping Serde registration (not a Serde!): {}", clazz);
continue;
}
Serde serde = (Serde) injector.instantiate(clazz);
injector.inject(serde);
ElideTypeConverter converter = clazz.getAnnotation(ElideTypeConverter.class);
Class baseType = converter.type();
registerCustomSerde(baseType, serde, converter.name());
for (Class type : converter.subTypes()) {
if (!baseType.isAssignableFrom(type)) {
throw new IllegalArgumentException("Mentioned type " + type + " not subtype of " + baseType);
}
registerCustomSerde(type, serde, converter.name());
}
}
}
Aggregations