Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
let graphql_type: GraphQLScalarType | undefined;
if (property.record_id) {
return new GraphQLNonNull(GraphQLID);
} else if (property.type_class === cormo.types.Number) {
graphql_type = GraphQLFloat;
} else if (property.type_class === cormo.types.Integer) {
graphql_type = GraphQLInt;
} else if (property.type_class === cormo.types.String) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Text) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Date) {
graphql_type = CrTimestamp;
} else if (property.type_class === cormo.types.Object) {
graphql_type = CrJson;
}
if (graphql_type && property.required) {
return new GraphQLNonNull(graphql_type);
}
return graphql_type;
}
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
let graphql_type: GraphQLScalarType | undefined;
if (property.record_id) {
return new GraphQLNonNull(GraphQLID);
} else if (property.type_class === cormo.types.Number) {
graphql_type = GraphQLFloat;
} else if (property.type_class === cormo.types.Integer) {
graphql_type = GraphQLInt;
} else if (property.type_class === cormo.types.String) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Text) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Date) {
graphql_type = CrTimestamp;
} else if (property.type_class === cormo.types.Object) {
graphql_type = CrJson;
}
if (graphql_type && property.required) {
return new GraphQLNonNull(graphql_type);
}
return graphql_type;
}
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
let graphql_type: GraphQLScalarType | undefined;
if (property.record_id) {
return new GraphQLNonNull(GraphQLID);
} else if (property.type_class === cormo.types.Number) {
graphql_type = GraphQLFloat;
} else if (property.type_class === cormo.types.Integer) {
graphql_type = GraphQLInt;
} else if (property.type_class === cormo.types.String) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Text) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Date) {
graphql_type = CrTimestamp;
} else if (property.type_class === cormo.types.Object) {
graphql_type = CrJson;
}
if (graphql_type && property.required) {
return new GraphQLNonNull(graphql_type);
}
return graphql_type;
}
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
let graphql_type: GraphQLScalarType | undefined;
if (property.record_id) {
return new GraphQLNonNull(GraphQLID);
} else if (property.type_class === cormo.types.Number) {
graphql_type = GraphQLFloat;
} else if (property.type_class === cormo.types.Integer) {
graphql_type = GraphQLInt;
} else if (property.type_class === cormo.types.String) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Text) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Date) {
graphql_type = CrTimestamp;
} else if (property.type_class === cormo.types.Object) {
graphql_type = CrJson;
}
if (graphql_type && property.required) {
return new GraphQLNonNull(graphql_type);
}
return graphql_type;
}
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
let graphql_type: GraphQLScalarType | undefined;
if (property.record_id) {
return new GraphQLNonNull(GraphQLID);
} else if (property.type_class === cormo.types.Number) {
graphql_type = GraphQLFloat;
} else if (property.type_class === cormo.types.Integer) {
graphql_type = GraphQLInt;
} else if (property.type_class === cormo.types.String) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Text) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Date) {
graphql_type = CrTimestamp;
} else if (property.type_class === cormo.types.Object) {
graphql_type = CrJson;
}
if (graphql_type && property.required) {
return new GraphQLNonNull(graphql_type);
}
return graphql_type;
}
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
let graphql_type: GraphQLScalarType | undefined;
if (property.record_id) {
return new GraphQLNonNull(GraphQLID);
} else if (property.type_class === cormo.types.Number) {
graphql_type = GraphQLFloat;
} else if (property.type_class === cormo.types.Integer) {
graphql_type = GraphQLInt;
} else if (property.type_class === cormo.types.String) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Text) {
graphql_type = GraphQLString;
} else if (property.type_class === cormo.types.Date) {
graphql_type = CrTimestamp;
} else if (property.type_class === cormo.types.Object) {
graphql_type = CrJson;
}
if (graphql_type && property.required) {
return new GraphQLNonNull(graphql_type);
}
return graphql_type;
function buildListQueryArgs(model_class: typeof cormo.BaseModel, options: IOptions) {
const list_query_args: GraphQLFieldConfigArgumentMap = {
};
for (const [column, property] of Object.entries(model_class._schema)) {
if (column === 'id') {
list_query_args[column + '_list'] = {
type: new GraphQLList(new GraphQLNonNull(GraphQLID)),
};
} else if (property.record_id) {
list_query_args[column] = {
type: GraphQLID,
};
} else if (property.type_class === cormo.types.String || property.type_class === cormo.types.Text) {
list_query_args[column] = {
type: GraphQLString,
};
list_query_args[column + '_istartswith'] = {
type: GraphQLString,
};
list_query_args[column + '_icontains'] = {
type: GraphQLString,
};
} else if (property.type_class === cormo.types.Integer) {
list_query_args[column] = {
type: GraphQLInt,
};
list_query_args[column + '_gte'] = {
type: GraphQLInt,
};
export function Column(options: {
enum?: any, type?: cormo.types.ColumnType
| cormo.types.ColumnType[],
} & IColumnBasicOptions): PropertyDecorator {
let cormo_type: cormo.types.ColumnType | cormo.types.ColumnType[];
if (options.enum) {
cormo_type = cormo.types.Integer;
} else {
cormo_type = options.type!;
}
const c = cormo.Column({
_graphql: {
description: options.description,
},
default_value: options.default_value,
name: options.name,
required: options.required,
type: cormo_type,
unique: options.unique,
});
return (target: object, propertyKey: string | symbol) => {
c(target, propertyKey);
};