Search in sources :

Example 1 with ScalarField

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;
}
Also used : GraphQLList(graphql.schema.GraphQLList) EnumField(org.codice.ddf.admin.api.fields.EnumField) Field(org.codice.ddf.admin.api.Field) ObjectField(org.codice.ddf.admin.api.fields.ObjectField) EnumField(org.codice.ddf.admin.api.fields.EnumField) ListField(org.codice.ddf.admin.api.fields.ListField) ScalarField(org.codice.ddf.admin.api.fields.ScalarField) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) GraphQLOutputType(graphql.schema.GraphQLOutputType) ScalarField(org.codice.ddf.admin.api.fields.ScalarField) ObjectField(org.codice.ddf.admin.api.fields.ObjectField) ListField(org.codice.ddf.admin.api.fields.ListField) FunctionDataFetcherException(org.codice.ddf.graphql.FunctionDataFetcherException)

Example 2 with ScalarField

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;
}
Also used : GraphQLInputType(graphql.schema.GraphQLInputType) GraphQLList(graphql.schema.GraphQLList) EnumField(org.codice.ddf.admin.api.fields.EnumField) Field(org.codice.ddf.admin.api.Field) ObjectField(org.codice.ddf.admin.api.fields.ObjectField) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) EnumField(org.codice.ddf.admin.api.fields.EnumField) ListField(org.codice.ddf.admin.api.fields.ListField) ScalarField(org.codice.ddf.admin.api.fields.ScalarField) ScalarField(org.codice.ddf.admin.api.fields.ScalarField) ObjectField(org.codice.ddf.admin.api.fields.ObjectField) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) ListField(org.codice.ddf.admin.api.fields.ListField)

Aggregations

GraphQLList (graphql.schema.GraphQLList)2 Field (org.codice.ddf.admin.api.Field)2 EnumField (org.codice.ddf.admin.api.fields.EnumField)2 ListField (org.codice.ddf.admin.api.fields.ListField)2 ObjectField (org.codice.ddf.admin.api.fields.ObjectField)2 ScalarField (org.codice.ddf.admin.api.fields.ScalarField)2 GraphQLInputObjectField (graphql.schema.GraphQLInputObjectField)1 GraphQLInputType (graphql.schema.GraphQLInputType)1 GraphQLOutputType (graphql.schema.GraphQLOutputType)1 FunctionField (org.codice.ddf.admin.api.fields.FunctionField)1 FunctionDataFetcherException (org.codice.ddf.graphql.FunctionDataFetcherException)1