Skip to content

Commit

Permalink
support for Sequelize.REAL (mickhansen#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuele Tonello authored and mickhansen committed Nov 7, 2018
1 parent b036ef3 commit d392090
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/typeMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
BOOLEAN,
ENUM,
FLOAT,
REAL,
CHAR,
DECIMAL,
DOUBLE,
Expand All @@ -54,7 +55,8 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
TIME,
ARRAY,
VIRTUAL,
JSON
JSON,
JSONB
} = sequelizeTypes;

// Map of special characters
Expand All @@ -67,6 +69,7 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
if (sequelizeType instanceof BOOLEAN) return GraphQLBoolean;

if (sequelizeType instanceof FLOAT ||
sequelizeType instanceof REAL ||
sequelizeType instanceof DOUBLE) return GraphQLFloat;

if (sequelizeType instanceof DATE) {
Expand Down Expand Up @@ -110,7 +113,8 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
return returnType;
}

if (sequelizeType instanceof JSON) {
if (sequelizeType instanceof JSONB ||
sequelizeType instanceof JSON) {
return JSONType;
}

Expand Down
6 changes: 6 additions & 0 deletions test/unit/typeMapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
BOOLEAN,
ENUM,
FLOAT,
REAL,
CHAR,
DECIMAL,
DOUBLE,
Expand Down Expand Up @@ -138,6 +139,11 @@ describe('typeMapper', () => {
});
});

describe('REAL', function () {
it('should map to GraphQLFloat', function () {
expect(toGraphQL(new REAL(), Sequelize)).to.equal(GraphQLFloat);
});
});

describe('INTEGER', function () {
it('should map to GraphQLInt', function () {
Expand Down

0 comments on commit d392090

Please sign in to comment.