use of graphql.schema.GraphQLInputType in project graphql-java by graphql-java.
the class SchemaGeneratorHelper method buildDirectiveArgument.
private GraphQLArgument buildDirectiveArgument(Argument arg) {
GraphQLArgument.Builder builder = GraphQLArgument.newArgument();
builder.name(arg.getName());
GraphQLInputType inputType = buildDirectiveInputType(arg.getValue());
builder.type(inputType);
builder.defaultValue(buildValue(arg.getValue(), inputType));
return builder.build();
}
use of graphql.schema.GraphQLInputType in project admin-console-beta by connexta.
the class GraphQLTransformInput method fieldTypeToGraphQLInputType.
@SuppressWarnings("squid:S00112")
public GraphQLInputType fieldTypeToGraphQLInputType(Field field) {
if (inputTypesProvider.isTypePresent(field.getFieldType())) {
return inputTypesProvider.getType(field.getFieldType());
}
GraphQLInputType type = null;
if (field instanceof ObjectField) {
type = objectFieldToGraphQLInputType((ObjectField) field);
} else if (field instanceof EnumField) {
type = transformEnum.enumFieldToGraphQLEnumType((EnumField) field);
} else if (field instanceof ListField) {
try {
type = new GraphQLList(fieldTypeToGraphQLInputType(((ListField<Field>) field).createListEntry()));
} catch (Exception e) {
throw new RuntimeException("Unable to build field list content type for input type: " + field.getFieldName());
}
} else if (field instanceof ScalarField) {
type = transformScalars.resolveScalarType((ScalarField) field);
}
if (type == null) {
throw new RuntimeException("Error transforming input field to GraphQLInputType. Unknown field type: " + field.getClass());
}
inputTypesProvider.addType(field.getFieldType(), type);
return type;
}
use of graphql.schema.GraphQLInputType in project ontrack by nemerosa.
the class GraphQLBeanConverter method asInputType.
public static GraphQLInputType asInputType(Class<?> type) {
GraphQLInputObjectType.Builder builder = newInputObject().name(type.getSimpleName());
// Gets the properties for the type
for (PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(type)) {
if (descriptor.getReadMethod() != null) {
String name = descriptor.getName();
String description = descriptor.getShortDescription();
GraphQLInputType scalarType = getScalarType(descriptor.getPropertyType());
if (scalarType != null) {
builder = builder.field(field -> field.name(name).description(description).type(scalarType));
}
}
}
// OK
return builder.build();
}
Aggregations