Skip to content

Commit

Permalink
add support for uuidv4 data type (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
realies authored and mickhansen committed Dec 20, 2019
1 parent 5774259 commit 4538569
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/typeMapper.js
Expand Up @@ -50,6 +50,7 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
STRING,
TEXT,
UUID,
UUIDV4,
DATE,
DATEONLY,
TIME,
Expand Down Expand Up @@ -80,6 +81,7 @@ export function toGraphQL(sequelizeType, sequelizeTypes) {
sequelizeType instanceof STRING ||
sequelizeType instanceof TEXT ||
sequelizeType instanceof UUID ||
sequelizeType instanceof UUIDV4 ||
sequelizeType instanceof DATEONLY ||
sequelizeType instanceof TIME ||
sequelizeType instanceof BIGINT ||
Expand Down
16 changes: 16 additions & 0 deletions test/unit/defaultArgs.test.js
Expand Up @@ -59,6 +59,22 @@ describe('defaultArgs', function () {
expect(args.uuid.type).to.equal(GraphQLString);
});

it('should return a key for a UUIDV4 primary key', function () {
var Model
, args;

Model = sequelize.define('DefaultArgModel', {
uuidv4: {
type: Sequelize.UUIDV4,
primaryKey: true
}
});

args = defaultArgs(Model);

expect(args.uuidv4.type).to.equal(GraphQLString);
});

it('should return multiple keys for a compound primary key', function () {
var Model
, args;
Expand Down
7 changes: 7 additions & 0 deletions test/unit/typeMapper.test.js
Expand Up @@ -18,6 +18,7 @@ const {
STRING,
TEXT,
UUID,
UUIDV4,
DATE,
DATEONLY,
TIME,
Expand Down Expand Up @@ -175,6 +176,12 @@ describe('typeMapper', () => {
});
});

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

describe('VIRTUAL', function () {

it('should map to the sequelize return type', function () {
Expand Down

0 comments on commit 4538569

Please sign in to comment.