static GraphQLType convertPropertyType()

in graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/converters/UnomiToGraphQLConverter.java [37:84]


    static GraphQLType convertPropertyType(final String type) {
        String normalizedType = type;
        GraphQLType graphQLType;
        boolean isArray = false;
        boolean isMandatory = false;
        if (normalizedType.endsWith("!")) {
            isMandatory = true;
            normalizedType = normalizedType.substring(0, normalizedType.length() - 1);
        }
        if (normalizedType.startsWith("[") && normalizedType.endsWith("]")) {
            isArray = true;
            normalizedType = normalizedType.substring(1, normalizedType.length() - 1);
        }
        switch (normalizedType) {
            case "id":
                isMandatory = true; // force mandatory for id
                graphQLType = Scalars.GraphQLID;
                break;
            case "integer":
                graphQLType = Scalars.GraphQLInt;
                break;
            case "long":
                graphQLType = Scalars.GraphQLLong;
                break;
            case "float":
                graphQLType = Scalars.GraphQLFloat;
                break;
            case "set":
            case "json":
                graphQLType = JSONFunction.JSON_SCALAR;
                break;
            case "geopoint":
                graphQLType = GeoPointFunction.GEOPOINT_SCALAR;
                break;
            case "date":
                graphQLType = DateTimeFunction.DATE_TIME_SCALAR;
                break;
            case "boolean":
                graphQLType = Scalars.GraphQLBoolean;
                break;
            case "string":
            default:
                graphQLType = Scalars.GraphQLString;
                break;
        }
        graphQLType = isArray ? GraphQLList.list(graphQLType) : graphQLType;
        return isMandatory ? GraphQLNonNull.nonNull(graphQLType) : graphQLType;
    }