Skip to content

Commit 4556d77

Browse files
Brandon DailBrandon Dail
authored andcommitted
Updated typeMapper implementation
1 parent 72c69ce commit 4556d77

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/typeMapper.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,29 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
3636
if (sequelizeType instanceof STRING ||
3737
sequelizeType instanceof TEXT ||
3838
sequelizeType instanceof UUID ||
39-
sequelizeType instanceof DATE
40-
) return GraphQLString;
39+
sequelizeType instanceof DATE) {
40+
return GraphQLString
41+
}
4142

4243
if (sequelizeType instanceof ARRAY) {
4344
let elementType = toGraphQL(sequelizeType.type, sequelizeTypes);
44-
return GraphQLList(elementType);
45+
return new GraphQLList(elementType);
4546
}
4647

4748
if (sequelizeType instanceof ENUM) {
4849
return new GraphQLEnumType({
49-
values: sequelizeType.values.reduce((obj, value) => {
50-
obj[value] = {value};
51-
return obj;
52-
}, {})});
50+
values: sequelizeType.values.reduce((obj, value) => {
51+
obj[value] = {value};
52+
return obj;
53+
}, {})
54+
});
5355
}
5456

5557
if (sequelizeType instanceof VIRTUAL) {
56-
return toGraphQL(sequelizeType.returnType, sequelizeTypes);
58+
let returnType = sequelizeType.returnType
59+
? toGraphQL(sequelizeType.returnType, sequelizeTypes)
60+
: GraphQLString;
61+
return returnType;
5762
}
5863

5964
throw new Error(`Unable to convert ${sequelizeType.key || sequelizeType.toSql()} to a GraphQL type`);

0 commit comments

Comments
 (0)