use of org.codice.ddf.admin.api.fields.ScalarField in project admin-console-beta by connexta.
the class GraphQLTransformOutput method fieldToGraphQLOutputType.
@SuppressWarnings("squid:S00112")
public GraphQLOutputType fieldToGraphQLOutputType(Field field) {
if (outputTypeProvider.isTypePresent(field.getFieldType())) {
return outputTypeProvider.getType(field.getFieldType());
}
GraphQLOutputType type = null;
if (field instanceof ObjectField) {
type = fieldToGraphQLObjectType((ObjectField) field);
} else if (field instanceof EnumField) {
type = transformEnum.enumFieldToGraphQLEnumType((EnumField) field);
} else if (field instanceof ListField) {
try {
type = new GraphQLList(fieldToGraphQLOutputType(((ListField<Field>) field).createListEntry()));
} catch (Exception e) {
throw new RuntimeException("Unable to build field list content type for output type: " + field.getFieldName());
}
} else if (field instanceof ScalarField) {
type = transformScalar.resolveScalarType((ScalarField) field);
}
if (type == null) {
throw new RuntimeException("Error transforming output field to GraphQLOutputType. Unknown field base type: " + field.getClass());
}
outputTypeProvider.addType(field.getFieldType(), type);
return type;
}
use of org.codice.ddf.admin.api.fields.ScalarField 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;
}
Aggregations